07-30-2009, 03:30 AM
You can pass a variable to a string then pass that string to the DB Query:
as you can see I'm just getting the count back
Code:
ZipCode="12345"
sqlstring= "SELECT count(*) FROM LOCCITY WHERE LOCCITY.LOCZIPCODESTART LIKE '"&ZipCode&"%' "
Set Rec = CreateObject("ADODB.Recordset")
SQL= ""&sqlstring&" "
Rec.open SQL ,conn
as you can see I'm just getting the count back