- Joined
- Sep 17, 2008
- Messages
- 3
- Reaction score
- 0
Hi there,
I'm having some trouble with a few find buttons on an access form.
It's a contacts database and i have a standard 'find' button beside every field, these buttons were created with the wizard and the vb changed to set the focus to a specific field. So every field has its own search facility. The vb source for this 'find' button is as follows;
I also want a 'find' button that searches every field on the form, not just one in particular as described above, so i created another find button with the following source;
The problem arises when you use the searchAllButton (2nd example) then you try to use the findFirstName button (1st example) and it changes the focus to the full form, not just the firstName field, so you change the 'Look in' field (in the search box that pops up) to firstName. It seems to work OK, but then when you then try to use the searchAllButton again (2nd example) it keeps giving an error message like the focus is on the searchAllButton instead of the full form, the error it gives is;
Does anyone know a way around this?
I'm having some trouble with a few find buttons on an access form.
It's a contacts database and i have a standard 'find' button beside every field, these buttons were created with the wizard and the vb changed to set the focus to a specific field. So every field has its own search facility. The vb source for this 'find' button is as follows;
Private Sub findFirstName_Click()
On Error GoTo Err_findFirstName_Click
Err_findFirstName_Click:
MsgBox Err.Description
Resume Exit_findFirstName_Click
End Sub
This all works fine.On Error GoTo Err_findFirstName_Click
Me.firstName.SetFocusDoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_findFirstName_Click:Exit Sub
Err_findFirstName_Click:
MsgBox Err.Description
Resume Exit_findFirstName_Click
End Sub
I also want a 'find' button that searches every field on the form, not just one in particular as described above, so i created another find button with the following source;
Private Sub searchAllButton_Click()
On Error GoTo Err_searchAllButton_Click
Err_searchAllButton_Click:
MsgBox Err.Description
Resume Exit_searchAllButton_Click
End Sub
This also appears to work fine. On Error GoTo Err_searchAllButton_Click
Me.Form.SetFocusDoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_searchAllButton_Click:Exit Sub
Err_searchAllButton_Click:
MsgBox Err.Description
Resume Exit_searchAllButton_Click
End Sub
The problem arises when you use the searchAllButton (2nd example) then you try to use the findFirstName button (1st example) and it changes the focus to the full form, not just the firstName field, so you change the 'Look in' field (in the search box that pops up) to firstName. It seems to work OK, but then when you then try to use the searchAllButton again (2nd example) it keeps giving an error message like the focus is on the searchAllButton instead of the full form, the error it gives is;
The control 'searchAllButton' the macro is attempting to search can't be searched
I've had a good look around the net for a solution to this but i'm stumped. Its almost as if the focus does not get changed as it should, like the focus as set in one of the 'find' buttons is taking precedence over the other and confusing things.
Does anyone know a way around this?