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

SQL in form recordset open 2

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
I am opening a recordset with the basic code below. "Policy" is a string variable. What I would now like to do is to use the leading and lagging * wildcard and like to pull back similar records. I have tried seemingly every conceivable iteration of adding the "*" before and after policy to no avail. Anybody know the correct synatax?

Thank you!

This works, but it doesn't use like & wildcard symbol * for the string 'Policy' variable

FROM Master WHERE (master.policy_number)= " & "'" & Policy & "'", CurrentProject.Connection
 
Couple issues... in SQL * is not the wildcard % is. The other is use the LIKE keyword rather than =.

Like so:
Code:
(master.policy_number) LIKE " & "'%" & Policy & "%'"...

Just a thought.

"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
 
In ANSI SQL and SQL server % is the wildcard for any number of characters. In Jet SQL (Access) the * is the correct wildcard. [red]?[/red] is a wildcard for a single character that must be there.

But otherwise Acent's notes about using the wildcard is correct.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top