SQL with multiple similar queries

L

lbsstacey

I have designed a database where I have many queries that look the same but
they each refer to a different table that contains specific client
information. I run my queries from a process form that contains an
abbreviated name that refers to each client. I am wondering how I can change
my query to instead of referring to the table "Terms_BE" I can refer to a
variable "Terms _" & [Forms]![MainForm]![AbbrName]

INSERT INTO Terms_BE ( SubSSn, MBRSSn, Rel, [Employee_First Name],
[Employee_Middle Initial], [Employee_Last Name], EffDate, TermDate, Field21,
Expr1 )
 
Joined
Feb 6, 2009
Messages
6
Reaction score
0
Why don't you make the query dynamic, something like;

Dim db As DAO.Database
Dim qry_x As DAO.QueryDef
Dim x as String

Set db = CurrentDb
Set qry_x = db.QueryDefs("Your_Query")

x = "Terms_BE" 'Table Name

qry_x.SQL = "INSERT INTO " & x & " ( SubSSn, MBRSSn, Rel, [Employee_First Name],
[Employee_Middle Initial], [Employee_Last Name], EffDate, TermDate, Field21,
Expr1 )"

Try that
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top