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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use Like "*" in Module to create Filter Variable for recordset

Status
Not open for further replies.

Poduska

Technical User
Dec 3, 2002
108
0
0
US
I have a combo box I am using for a criteria for a recordset filter in VBA modual and I want it to work if the box is NULL or is populated

I am trying to take this from a query which works fine if the Combo box is null or is populated
Code:
Like "*" & [Forms]![frmDirectorsTotals]![cboDirector]

I have this which works so far in my code. I am using the variable "DirectorID" as a filter on the recordset. I have to use the filter as the recordset is created from a union query of 22 queries.
This also works IF the combo box is not null
Code:
DirectorID = Eval("Forms![frmDirectorsTotals]!cboxDirector.column(0)")

But when I attempt to make them work together I get "Mismatch" error.
I have been working with this bit of code
Code:
DirectorID = "Like """ * """ & " & Eval("[Forms]![frmDirectorsTotals]![cboxdirector].column(0)")

What does it take to add the Like "*" to my assignment statement to DirectorID?

Can someone please embarass me with something simple that I stupidly overlooked? :)

Thanks
 
What about this ?
Code:
DirectorID = "Like '*" & Forms!frmDirectorsTotals!cboxdirector.Column(0) & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
If you use it in vba code for query, Please try this,
"WHERE DirectorID Like " & chr(34) & "*" & Eval("[Forms]![frmDirectorsTotals]![cboxdirector].column(0)") & chr(34)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top