Full Version: Wilcard syntax - VBA SQL for rowsource
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
MattJ
I'm attempting to set a row source of a list box. The only field which has any critera has a text datatype, for which I would like to use a variable with a wildcard (*).
So far, if I only use the variable as the criteria, the statement performs as intended. If I try to include the asterisk, I get nothing. and darned if I can figure out the syntax.

CODE
"SELECT tblMessage.MsgPK, tblMessage.Date_Stamp, tblMessage.Msg " & _
                            "FROM tblMessage " & _
                            "Where (((tblMessage.Msg) =[color="red"] '" & strSitePrefix & "'[/color]))" & _
                            "ORDER BY tblMessage.Date_Stamp DESC;"


strSitePrefix is a 3 character text string (example ABC), and I would like the criteria to ultimately be "*ABC*"

Thanks,
Matt
dashiellx2000
Try:

CODE
Where (((tblMessage.Msg) = '*" & strSitePrefix & "*'))" & _


HTH.
MattJ
So simple... crazy.gif
Thanks William
dashiellx2000
Glad I could help. Good luck with your project.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.