Using LIKE operator in an SQL statement not working. Please help. (1 Viewer)

ToddMac

New member
Local time
Today, 12:23
Joined
Nov 2, 2019
Messages
4
Not sure what I am doing wrong and I am sure that it is a formatting error.


This works:
Code:
!lstSel.RowSource = "Select ag_auto, PID, AgreeNum, Contractor, LandOwner, Type FROM qryAgreeSel WHERE ag_del = 0 AND PID Like '*224*' Order by PID"

This doesn't:
Code:
!lstSel.RowSource = "Select ag_auto, PID, AgreeNum, Contractor, LandOwner, Type FROM qryAgreeSel WHERE ag_del = 0 AND PID Like '* & !txtPre & *' Order by PID"
Any help tweaking this is appreciated.



Thank you.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:23
Joined
Oct 29, 2018
Messages
21,358
Hi Todd. Welcome to AWF!


Try it this way:
Code:
...WHERE ag_del = 0 AND PID Like '*[COLOR=red]"[/COLOR] & !txtPre & [COLOR=red]"[/COLOR]*' Order by PID"
 

ToddMac

New member
Local time
Today, 12:23
Joined
Nov 2, 2019
Messages
4
Hi Todd. Welcome to AWF!


Try it this way:
Code:
...WHERE ag_del = 0 AND PID Like '*[COLOR=red]"[/COLOR] & !txtPre & [COLOR=red]"[/COLOR]*' Order by PID"


Sweet. I missed that.



Works perfectly.



Glad to be here!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:23
Joined
Oct 29, 2018
Messages
21,358
Hi. Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Top Bottom