passing a variable into a sql

  • Thread starter Thread starter charawh
  • Start date Start date
C

charawh

Guest
I am relatively new to access and hope that i can describe my problem adequatley. I am having a problem passing a variable into an sql statement. I need to find all sales to a specific customer. I have used an sql statment to determine the customers with sales on a specific day. now i need to input that customer as a variable in the second sql- there are multiple variables in the second sql that fills in an array.

any suggestions will be appreciated
 
Your SQL is, or can be, a string so you can use string concatenation. Like this:

dim sql1 as string
dim sql2 as string
dim db as databse
dim rst1 as recordset
dim rst2 as recordset

set db = currentdb()

sql1 = “SELECT * FROM [tablename] WHERE [EmployeeID] = 1”
set rst1 = openrecordset(sql1)

sql2 = “SELECT * FROM [tanle2_name] WHERE [Name] = “ & rst1!Employee_Name
set rst2 = openrecordset(sql2)

HTH

HiArt
 

Users who are viewing this thread

Back
Top Bottom