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

SQL Search

Status
Not open for further replies.

Chopstik

Technical User
Oct 24, 2001
2,180
US
Am trying to find the the MAX field that exists in a database where the first five characters fit whatever the user entry may be (in other words, it needs to be dynamic. I keep coming back with a syntax error near PurchaseOrderID. Here's my code, can anyone tell me what is happening? Thanks.

strTest = "SELECT MAX PurchaseOrderID FROM PurchaseOrder WHERE PurchaseOrderID LIKE '" & _
left(strPONum,5) & "'"
 
You need parens around the field name. Also, don't you need the wildcard % ?
strTest = "SELECT MAX(PurchaseOrderID) FROM PurchaseOrder WHERE PurchaseOrderID LIKE '" & _
left(strPONum,5) & "%'"

HTH,
Richie
 
Thanks, ros and rico, that helps a lot. Much appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top