I’ve run across a weird problem and I hope someone can shed some light on what is the issue. When the form’s “on current” code is executed, it will count the number of records in each of the subforms that match the user on the main form. This works without any issues. The problem is that some of the code is being skipped (for the lack of a better term).</SPAN>
The count is applied to a global variable</SPAN>
</SPAN>
After a value is assigned to the variables the code is run for each of the subforms. </SPAN>
Essentially this same bit of code is used for each subform except for button and other control names that are changed.</SPAN>
Now for the weird part, on the 5th</SPAN> subform, the code stops working. It doesn’t update the checkbox (lines 5 and 10). I’ve copied and pasted the code to a temporary button and when it is ran by itself, it works as advertised. While the code “should” run everything is there a way to force it to slow down and not go to the next bit without getting ahead of itself (for the lack of a better way to explain it)?</SPAN>
The count is applied to a global variable</SPAN>
Code:
</SPAN>
AdminCheck = DCount("MemberSSAN", "qryCurrentAdminDemo", "MemberSSAN='" & Me.txtSSAN & "'")</SPAN>
After a value is assigned to the variables the code is run for each of the subforms. </SPAN>
Code:
If AdminCheck = "0" Then '1 if there are no records</SPAN>
Me.lblCountAdminDemo.Caption = "" '2 removes Record X of Y text in label</SPAN>
Me.btnPrevAdminDemo.Visible = False '3 makes previous record button invisible</SPAN>
Me.btnNextAdminDemo.Visible = False '4 makes next record button invisible</SPAN>
Me.chkAdminDemo = False '5 unchecks box used to see if record exists in queries</SPAN>
Me.btnAddAdminDemote.Enabled = True '6 enables button to add record</SPAN>
Me.btnArchiveAdminDemote.Enabled = False '7 disables button to archive record (because there isn't one)</SPAN>
Me.btnDeleteAdminDemote.Enabled = False '8 disables button to delete record (because there isn't one)</SPAN>
Else '9 if there are records</SPAN>
Me.lblCountAdminDemo.Caption = frmAdminDemo.Form.CurrentRecord & " of " & AdminCheck 'updates Record X of Y label</SPAN>
Me.chkAdminDemo = True '10 unchecks box used to see if record exists in queries</SPAN>
Me.btnAddAdminDemote.Enabled = True '11 enables button to add record</SPAN>
Me.btnArchiveAdminDemote.Enabled = True '12 enables button to archive record</SPAN>
Me.btnDeleteAdminDemote.Enabled = True '13 enables button to delete record</SPAN>
If AdminCheck > 1 Then '14 if there is more than one record</SPAN>
Me.btnPrevAdminDemo.Visible = True '15 enables previous record button</SPAN>
Me.btnNextAdminDemo.Visible = True '16 enables next record button</SPAN>
Else '17 if there is only one record</SPAN>
Me.btnPrevAdminDemo.Visible = False '18 disables previous record button</SPAN>
Me.btnNextAdminDemo.Visible = False '19 enables next record button</SPAN>
End If</SPAN>
End If</SPAN>
Essentially this same bit of code is used for each subform except for button and other control names that are changed.</SPAN>
Now for the weird part, on the 5th</SPAN> subform, the code stops working. It doesn’t update the checkbox (lines 5 and 10). I’ve copied and pasted the code to a temporary button and when it is ran by itself, it works as advertised. While the code “should” run everything is there a way to force it to slow down and not go to the next bit without getting ahead of itself (for the lack of a better way to explain it)?</SPAN>