Iíve been working on a little application in Access 2007 for a couple months now, and I continue to be vexed by a mysterious
problem: every now and then, the comboboxes that I use to find records stop working. To be more specific, the comboboxes
themselves work, but the form continues to display the current record rather than navigating to the record selected from the
Basically, I have several similar forms that are used to view single records. (These forms are not related to each other,
but they are all designed the same way, and Iíve had this problem with all of them.) Each form has a couple of subforms (in
case that matters) and each has a command button named cmdFind. Because all of these forms are opened in read-only mode,
cmdFind sets the AllowEdits property of the main form to True and makes the searchbox visible.
The searchbox is a combobox that I originally created using the third option of the combobox wizard. I added a couple of
actions to the embedded macro to make the findbox invisible after an update, and I use an event procedure in the comboboxís
LostFocus event to set AllowEdits back to false.
As I mentioned, this method works just fine for a (seemingly random) period of time, then inexplicably stops working. When I
click cmdFind, the searchbox show up, but when a selection is made, all the other actions execute, but the form does not go
to the specified record. Instead, the current record reloads.
I havenít found another thread that describes this problems, so in the past, Iíve addressed it by deleting the searchbox and
re-creating it. To my frustration, this solution has proven to be temporary, and Iím finally irritated enough to figure out
Iím sure youíll be glad to know that Iíve converted all my macros to VBA (and trying to break the habit of using them
altogether). Since the DoCmd.SearchForRecord bit that the converter tool came up with didnít work, I starting using the
Me.RecordsetClone.FindFirst bit that Iíve found in this thread and others like it.
That works well (for now, anyway) on two of the three forms. One of my forms is holding out, though, and is still doing what
I described above. Iíll post this formís code for good measure, but Iím thinking the problem has to be elsewhere. Itís
probably something simple. Any ideas?
Private Sub cmdFind_Click()
Me.AllowEdits = True
Me.cboFindEmp.Visible = True
Me.cmdNew.Enabled = False
Me.cmdEdit.Enabled = False
Me.cmdPrint.Enabled = False
Me.cmdDone.Enabled = False
Me.cmdCancel.Visible = True
Me.cmdFind.Enabled = False
Private Sub cboFindEmp_AfterUpdate()
On Error GoTo cboFindEmp_AfterUpdate_Err
Me.RecordsetClone.FindFirst "[StaffID] = " & Me![cboFindEmp]
Me.Bookmark = Me.RecordsetClone.Bookmark
DoCmd.SetProperty "cmdNew", acPropertyEnabled, "-1"
DoCmd.SetProperty "cmdEdit", acPropertyEnabled, "-1"
DoCmd.SetProperty "cmdFind", acPropertyEnabled, "-1"
DoCmd.SetProperty "cmdDone", acPropertyEnabled, "-1"
DoCmd.SetProperty "cmdPrint", acPropertyEnabled, "-1"
DoCmd.SetProperty "cmdCancel", acPropertyVisible, "0"
DoCmd.SetProperty "cboFindEmp", acPropertyVisible, "0"
Private Sub cboFindEmp_LostFocus()
Me.AllowEdits = False