In a query I have a record field that I need to specify criteria for. The records in that field are of the form 2xxxxx, 3xxxxx - 9xxxxx ect. (the 2,3,4,5,6,7,8,9 denote different systems). Well, I have built a form with 9 checkboxes for the user to select which forms to run a query on. The problem is that I can't get the syntax correct on joining the different options. I have looked at the massively long tek tip about building user forms, but that really didn't make sense to me.
I even tried setting up 9 different variables in the critera section of the query, but if you leave out just one the query gives you the whole record set. So instead of doing the 9 if's, how can I join them into 1 string to search like this: Like"4*" AND Like"6*" AND Like"7*" depending on what the user selects?
If system2.Value = True Then
search2.Value = "2"
End If
If system3.Value = True Then
search3.Value = "3"
End If
If system4.Value = True Then
search4.Value = "4"
End If
If system5.Value = True Then
search5.Value = "5"
End If
If system6.Value = True Then
search6.Value = "6"
End If
If system7.Value = True Then
search7.Value = "7"
End If
If system8.Value = True Then
search8.Value = "8"
End If
If system9.Value = True Then
search9.Value = "9"
End If
Also, right now I am outputing the results back to the user form and then calling the query. Is there a way to send a variable directly back to the criteria field without it being on the user form? Thanks.
Eric.
I even tried setting up 9 different variables in the critera section of the query, but if you leave out just one the query gives you the whole record set. So instead of doing the 9 if's, how can I join them into 1 string to search like this: Like"4*" AND Like"6*" AND Like"7*" depending on what the user selects?
If system2.Value = True Then
search2.Value = "2"
End If
If system3.Value = True Then
search3.Value = "3"
End If
If system4.Value = True Then
search4.Value = "4"
End If
If system5.Value = True Then
search5.Value = "5"
End If
If system6.Value = True Then
search6.Value = "6"
End If
If system7.Value = True Then
search7.Value = "7"
End If
If system8.Value = True Then
search8.Value = "8"
End If
If system9.Value = True Then
search9.Value = "9"
End If
Also, right now I am outputing the results back to the user form and then calling the query. Is there a way to send a variable directly back to the criteria field without it being on the user form? Thanks.
Eric.