"Find" command button in subform error

LeBron

Registered User.
Local time
Today, 05:58
Joined
May 29, 2009
Messages
17
I've created a form which contains a subform, with a "Find" command button (among others) in both the "main" form and subform. It works fine in the main form but does not work in the subform - it simply doesn't find anything. The other command buttons in the subform, Save, Delete and Add, work perfectly.

When I open just the subform on its own, the Find button does work.

Any ideas why it isn't working? When the "Find" window appears I've tried various options but nothing seems to work.
 
What is the code behind the Find button?

Option Compare Database

Private Sub Delete_Record_Contact_Click()
On Error GoTo Err_Delete_Record_Contact_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Delete_Record_Contact_Click:
Exit Sub

Err_Delete_Record_Contact_Click:
MsgBox Err.Description
Resume Exit_Delete_Record_Contact_Click

End Sub
Private Sub Save_Record_Contacts_Click()
On Error GoTo Err_Save_Record_Contacts_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Save_Record_Contacts_Click:
Exit Sub

Err_Save_Record_Contacts_Click:
MsgBox Err.Description
Resume Exit_Save_Record_Contacts_Click

End Sub
Private Sub Add_Record_Contacts_Click()
On Error GoTo Err_Add_Record_Contacts_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Record_Contacts_Click:
Exit Sub

Err_Add_Record_Contacts_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Contacts_Click

End Sub
Private Sub Save_Contact_Click()
On Error GoTo Err_Save_Contact_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Save_Contact_Click:
Exit Sub

Err_Save_Contact_Click:
MsgBox Err.Description
Resume Exit_Save_Contact_Click

End Sub
Private Sub Delete_Contact_Click()
On Error GoTo Err_Delete_Contact_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_Delete_Contact_Click:
Exit Sub

Err_Delete_Contact_Click:
MsgBox Err.Description
Resume Exit_Delete_Contact_Click

End Sub
Private Sub Add_Contact_Click()
On Error GoTo Err_Add_Contact_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_Contact_Click:
Exit Sub

Err_Add_Contact_Click:
MsgBox Err.Description
Resume Exit_Add_Contact_Click

End Sub
Private Sub Find_Contact_Click()
On Error GoTo Err_Find_Contact_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Find_Contact_Click:
Exit Sub

Err_Find_Contact_Click:
MsgBox Err.Description
Resume Exit_Find_Contact_Click

End Sub
 
Well, you posted all the code for the form instead of just the code behind the button.
I personally dont know what each acMenuVer does, so cant decipher what each one does.

If I had to take a guess....
When you put the code on the subform...did that subform start out as a regular form? I'm guessing it has to do with being on the subform and how it's being referenced.
 
Well, you posted all the code for the form instead of just the code behind the button.
I personally dont know what each acMenuVer does, so cant decipher what each one does.

If I had to take a guess....
When you put the code on the subform...did that subform start out as a regular form? I'm guessing it has to do with being on the subform and how it's being referenced.

I've found that it does work when the record in the main form has more than one related records in the subform, but it's unable to search past the record currently open in the main form.

How do I find the code for just that button rather than the whole form?
 
Open up the form/subform in Design Mode. Right click on the button and select Build Event. That will open up the VBA Editor and take you to the event for the button.

You could always strip out any sensative data and post your database as well. Might get you a response much quicker...just remember, that if using Acess 2007 to save it as a MDB. Not everybody runs Acess 2007
 
Well, you posted all the code for the form instead of just the code behind the button.
I personally dont know what each acMenuVer does, so cant decipher what each one does.

If I had to take a guess....
When you put the code on the subform...did that subform start out as a regular form? I'm guessing it has to do with being on the subform and how it's being referenced.

I believe that the code he is having problems with is the code below, but I do not know what to say about it.
Code:
Private Sub Find_Contact_Click()
On Error GoTo Err_Find_Contact_Click


Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70

Exit_Find_Contact_Click:
Exit Sub

Err_Find_Contact_Click:
MsgBox Err.Description
Resume Exit_Find_Contact_Click

End Sub
 

Users who are viewing this thread

Back
Top Bottom