combo and text boxes to search a form

T

Tyler

I have 3 fields, two of which are combo boxes the third is a text
box. I can get it to search using both the combo boxes but not all
three together, my code looks like the following.

Private Sub Searches_the_Main_Form_Click()
On Error GoTo Err_Searches_the_Main_Form_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Main"

stLinkCriteria = "[Concession_or_Range?]='" & Me!
[Concession_or_Range?] & "'"
stLinkCriteria = stLinkCriteria & " AND [Concession_Range_Number]='" &
Me![Concession_Range_Number] & "'"

If Not IsNull(Me.txtPlanLot) Then

strWhere = strWhere & " AND [Plan Lot] =""" & Me.txtPlanLot & """ "
End If

DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria


any suggestions on how i would fix this problem?
 
G

Guest

I don't see how strWhere is declared or used in the link criteria?
Also, don't use special characters like '?' in column names and don't create
any column names with embedded spaces - then you wont need to use the braces
[] around your column names - makes life a LOT easier.

-Dorian
 
T

Tyler

i've changed it to

stDocName = "Main"

stLinkCriteria = "[Concession_or_Range?]='" & Me!
[Concession_or_Range?] & "'"
stLinkCriteria = stLinkCriteria & " AND [Concession_Range_Number]='" &
Me![Concession_Range_Number] & "'"
stLinkCriteria = stLinkCriteria & " AND [Plan Lot]='" & Me!
[txtPlanLot] & "'"

but this still does not work, the two combo boxes on their own work
fine, i just need to add the text box
 

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