Subform Requery & 2465 Runtime Error

C

cunger28

I have a subform (sub_CompleteInstalls) that has a simple search function
added. Search button (cmd_Search) simply has the syntax:

Private Sub cmd_Search_Click()
Forms![sub_CompleteInstalls].Form.Requery
End Sub

The two search fields are labeled as [srch_WO] and [srch_Tech] within my
subform.

With the sub form opened by itself the code works and requeries just fine.

This sub form is then placed inside the main form (main_NetPromoter).
Whenever I double click the main form to open it. I first receive an Enter
Parameter Value prompt for my two search fields

Forms!sub_CompleteInstalls!srch_WO
Forms!sub_CompleteInstalls!srch_Tech

Once the main form opens, I then click the search button (cmd_Search) only
to receive a VBA error:

"Run-time error '2465':

Microsoft Office Access can't find the field 'sub_CompleteInstalls' referred
to in your expression."

I'm thinking it has to do with the syntax in my subform Search command button
Forms![sub_CompleteInstalls].Form.Requery

Thanks,
 
B

Beetle

You need to change the syntax in your command button code *and*
the criteria in your query.

I'm not clear if the Search button is in the main form or the subform.
If it is in the subform, all you should need is;

Me.Requery

If it is in the main form then;

Me![sub_CompleteInstalls].Form.Requery

The criteria in your query should be;

Forms![main_NetPromoter]![sub_CompleteInstalls].Form![srch_WO]
Forms![main_NetPromoter]![sub_CompleteInstalls].Form![srch_Tech]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top