Wednesday, 6 July 2016

Troubleshooting:Auto Numbering Field Error

Auto Numbering Field

I'm not sure this will be easy to explain, but I'll do my best. 
Part 1.
I have a subform called frmGoalsAndObjectives within the parent form frmIEP.  On the subform there is a field named NumGoal.  I need for this field to automatically begin numbering at 1 each time a new IEP is started.  Each time a new goal is started within
the same IEP, the number would increase by 1, thus next goal would be 2.  One thing that needs to be kept in mind is if the user closes the form and reopens to finish at a later time, we would need to be able to continue with the numbering sequence.  As mentioned,
each time a new IEP is started the numbering for each goal (NumGoal) needs to start over at 1. 

Part 2.

The subform frmGoalsAndObjectives also has a subform named frmObjectiveSubform with a field named ObjectiveNum.  I need to be able to do something similar with this field, however with a bit of a twist.  The numbering needs to be as such: 1.1  Where 1:1
represents goal 1, objective 1.  If we add a new objective to goal one, we would have the next objective being 1.2 and so on.  If a new goal is started, the first objective of the new goal would be numbered 2.1 and the next objective would be 2.2 and so on. 
Again, each time a new IEP is started the goal needs to begin at one and the objective needs to begin at 1.1
I assume this needs to be done programmatically, but how?
Any help or suggestions would be appreciated.

Solutions to the Problem Auto Numbering Field

Download SmartPCFixer to Fix It (Free)

You can do this very simply by setting the DefaultValue property of the relevant bound control in the subform's Current event procedure with code along these lines:

    Dim strCriteria As String

    strCriteria = "IEP_ID = " & Nz(Me.Parent.IEP_ID, 0)

    Me.NumGoal.DefaultValue = """" & _
        Nz(DMax("NumGoal", "Goals_Table", strCriteria), 0) + 1 & """"

This assumes that the subform is linked to the parent form on the keys named IEP_ID.  Goals_Table is the name of the subform's table.

In the nested subform do similarly but default the value returned by the DMax function to 1 rather than zero, and increment the value by 0.1

    Dim strCriteria As String

    strCriteria = "Goal_ID = " & Nz(Me.Parent.Goal_ID, 0)

    Me.ObjectiveNum.DefaultValue = """" & _
        Nz(DMax("ObjectiveNum", "Objectives_Table", strCriteria), 1) + 0.1 & """"

Note that in each case the values, although numeric, are wrapped in literal quotes characters.  This is because the DefaultValue property is always a string expression, regardless of the data type of the column to which the control is bound.

Exactly the same code should also be out in the AfterDelConfirm event procedure of each subform to allow for the possible deletion of rows in the subform.

You'll find this technique illustrated in the activities subform within the parents form in in my public databases folder at:!169

If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.

This little demo file does not take account of possible conflicts in a multi-user environment, however.  For ways of handling these see the CustomNumber demo in the same OneDrive folder.
PS:  I've assumed the value after the decimal point in the ObjectiveNum will never exceed 9.

Using Windows troubleshooter:

  • Click on Search on Charm bar and type Troubleshooting. Click on the very first option.
  • A new window will open. Click View all from the left pane.
  • Scroll down to the bottom and click on Windows update.
  • Troubleshooter window for Windows update will pop up. Click on NEXT. It may ask you for administrative permission.
  • The troubleshooter will automatically detect problems and fix it.
  • Now, close this window and try download/install the app which was previously showing error.

Recommended Method to Fix the Problem: Auto Numbering Field:

How to Fix Auto Numbering Field with SmartPCFixer?

1. Click the button to download Error Fixer . Install it on your system.  Run it, and it will scan your computer. The junk files will be shown in the list.

2. After the scan is done, you can see the errors and problems which need to be fixed.

3. When the Fixing part is done, your computer has been speeded up and the errors have been removed

Related: AMD Radeon HD 7800M Win8 not working [Anwsered],I can access the internet, get on facebook and get to hotmail, but I can't play games on facebook and I can't open or respond to my e-mails,I keep getting this Media Player error when I log on my computer. [Anwsered],[Anwsered] System Hanging on shutdown and restart,Unable to get the Vlookup property of the WorksheetFunction class,Solution to Error: Error: "0x81000032 make sure the C: drive is online and set to NTFS" when trying to backup to external hard drive.
,Troubleshoot:External Hard Drive not listed in Windows 7 backup wizard Error
,I'm always being signed off so annoying Tech Support
,Solution to Problem: Impossible to use Internet Explorer! I keep getting the same error message every time i try to use IE.
,Solution to Problem: Referencing data in another file
,Troubleshoot:Error: "0x81000032 make sure the C: drive is online and set to NTFS" when trying to backup to external hard drive. Error,External Hard Drive not listed in Windows 7 backup wizard Tech Support,Tech Support: I'm always being signed off so annoying,Solution to Problem: Impossible to use Internet Explorer! I keep getting the same error message every time i try to use IE.,Referencing data in Access using Excel [Anwsered],Need Best Way To Present Data [Anwsered],Same question but for windows 7 home edition,sometimes fullscreen won't activate [Solved],Solution to Error: We bought a new computer with windows 7 and it is constantly freezing. How do we fix this?,Solution to Error: Windows 8 update crash (2013-07-22)
Read More: Solution to Error: Assist me in getting a code,How to Fix Problem - apps\/tiles not opening since downloading windows 8.1?,[Solution] Avery Label and microft word 2010, message about wizard did not install correctly,Fast Solution to Error: Backup freezes at 43%,Solution to Error: ATI Mobility Radeon HD 5000 series (microsoft corporation WDDM v1.20) PROBLEM!,application not found error,any problems in a team where one has Windows XP and the other has Windows 7?,Application/Object-Defined Error,An Excel formula question where hours are totalled and cumulating,Anyone know the hardware email?

No comments:

Post a Comment