Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2010 - Search box result to a sub form?

Status
Not open for further replies.

colinmitton

Technical User
Feb 24, 2005
190
GB
I have a set up a search box to find businesses in a database.

The code looks like this:

Private Sub cmdSearch_Click()
Dim varWhere As Variant

varWhere = Null

If Not IsNothing(Me.txtCompany) Then
varWhere = "[3rdPartyBusinessName] LIKE '" & Me.txtCompany & "*'"
End If

If Not IsNothing(Me.txtTown) Then
varWhere = "[City] LIKE '" & Me.txtTown & "*'"
End If

If Not IsNothing(Me.cmbType) Then
varWhere = (varWhere + " AND ") & "[BusinessTypes] = " & Me.cmbType
End If

If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
Exit Sub
End If


DoCmd.OpenForm "frm_3rd_P_Bus_Res", WhereCondition:=varWhere

DoCmd.Close acForm, Me.Name

This worked fine until I decided to add a 'sub form' so I could select from a list of multiple results. The sub form is called: frm_QLookup_3rd_P_Business and is in the form frm_3rd_P_Bus_Res

How do I get me where condition to talk to 'sub form' element? I tried adjusting the if statement like so:
If Not IsNothing(Me.txtCompany) Then
varWhere = "[frm_3rd_P_Bus_Res!frm_QLookup_3rd_P_Business!3rdPartyBusinessName] LIKE '" & Me.txtCompany & "*'"
End If
Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top