Building a search form

T

Tony Williams

I want to build a search form. The search form will have one unbound combo
box "cmbcompany" which is based on a table "tblcompany" and another unbound
combo box "cmbmonth" (a date field format "mmmmyyyy") based on a table
"tblmonth" When the user has selected both combo boxes they will click on a
command button "cmdopen" which will open a form "frmfda" where "cmbmonth" is
equal to "txtmonthlabela" on the form and "cmbcompany" is equal to
"txtcompany" which is on the subform "subformFDA" which is part of the main
form "frmfda" I have tried adapting this code but can't see how I can add
the reference to the month and the subform.

Dim strform As String 'Name of form to open.
Dim strWhere As String 'Where condition for OpenForm.

strField = "txtcompany"


If Not IsNull(Me.cmbcompany) Then
strWhere = strWhere & " AND txtCompany = """ & Me.cmbcompany & """"

End If
strWhere = Mid(strWhere, 6) 'get rid of extra AND
Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenForm "frmFDA", acNormal, , strWhere

Can anyone help me to modify this code or is there a better way?
Thanks
Tony
 
T

Tony Williams

I've found a solution I managed to design my form without a subform.
Thanks
Tony
 

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