The form itself is really about as vanilla as one can get. I'm going to pursue the thought that perhaps in some way the form itself has become corrupted. I don't know if that's just "grasping for straws" or what, but it won't harm to at least investigate............. SIGH!
BTW, the Yes/No check boxes are only maintained in the DB as a single Yes/No field. The user just requested there be two boxes, which of course required a pair of AfterUpdates for each one.
Ignore this double "delayed by a black hole" post !!!!
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
OK, I think I see the problem, you have the form set as Data Entry= Yes so it will always open on a new record.
Change that to No and your original code should work. Also for the preferences check box pairs you could easily replace them with option groups (one for each pair) and bind the Option Group (the frame itself, not the two individual checkboxes) to the individual Yes/No fields from the table. No code needed
Cheers,
Vlad
Thank you Gicu, "Data Entry = No" solved the OP issue.
Now I get a 2950 error in the OnOpen code. That's a new one on me. Has all the messing around with the OP caused more problems?
Just a command button, "DoCmd.Close"
Not sure what you're suggesting with the "Option Group". There's only one field in the back-end DB. For display purposes, the AfterUpdate code simply for each check box sets its companion to "NOT", i.e.,
Code:Private Sub chkTxtNo_AfterUpdate() chkTxtYes = Not chkTxtNo bolChanges = True End Sub Private Sub chkTxtYes_AfterUpdate() chkTxtNo = Not chkTxtYes bolChanges = True End Sub
In the future:
Always check the value of the NoMatch property to determine whether the Find operation has succeeded.
If the search succeeds, NoMatch is False.
If it fails, NoMatch is True and the current record isn't defined.
In this case, you must position the current record pointer back to a valid record.
Recordset.FindFirst method (DAO)
Good luck with your project....Code:Private Sub Form_Open() Dim rs As DAO.Recordset Set rs = Me.RecordsetClone rs.FindFirst "[RegistryID] = " & lngRecID If rs.NoMatch Then 'NoMatch = TRUE '(lngRecID not found) MsgBox "Record not found." Else 'NoMatch = FALSE '(lngRecID found) Me.Bookmark = rs.Bookmark End If Set rs = Nothing End Sub
I don't see any command button on the form so I assume cmdFinished button is no longer there. This suggests you do not have "require variable declaration" checked in the VBA Project Options (it puts Option Explicit on top of all your modules). If it is not there just add it and try to compile. If the button does exist try instead to set its Tab Stop to 0 if you want it to be the first that gets focus.
Regarding the code you show, you do not need any of that if you use option groups instead. Remove the two checkboxes (chkTextYes,chkTextNo), add an option group with two check boxes (one for each field), set the labels and values (Yes=-1,No = 0) and bind the option group (frame) to the field:
Remove the code you have and try it. The option group will load and save whatever value the field has.
Cheers,
Vlad
Thanks Steve,
I will add the NoMatch to the code.
Bill