I'm trying to query a table based on the value of a variable (which comes from another table) but it doesn't work.
My code works like this.
Dim myVar as String
myVar = "1001"
AdoJobs.CommandType = adCmdText
AdoJobs.RecordSource = "SELECT * FROM Jobs, Clients WHERE Jobs.ClientID = Clients.ClientID AND Clients.ClientID = '1001'"
AdoJobs.Refresh
But it doesn't work like this!
Dim myVar as String
myVar = "1001"
AdoJobs.CommandType = adCmdText
AdoJobs.RecordSource = "SELECT * FROM Jobs, Clients WHERE Jobs.ClientID = Clients.ClientID AND Clients.ClientID = 'myVar'"
AdoJobs.Refresh
How do I make it work using a variable? Can someone show me how, actually write the code, cause I don't get it with a String. I can use queries with Dates, Numbers.. but this as me puzzeled.
Andre
My code works like this.
Dim myVar as String
myVar = "1001"
AdoJobs.CommandType = adCmdText
AdoJobs.RecordSource = "SELECT * FROM Jobs, Clients WHERE Jobs.ClientID = Clients.ClientID AND Clients.ClientID = '1001'"
AdoJobs.Refresh
But it doesn't work like this!
Dim myVar as String
myVar = "1001"
AdoJobs.CommandType = adCmdText
AdoJobs.RecordSource = "SELECT * FROM Jobs, Clients WHERE Jobs.ClientID = Clients.ClientID AND Clients.ClientID = 'myVar'"
AdoJobs.Refresh
How do I make it work using a variable? Can someone show me how, actually write the code, cause I don't get it with a String. I can use queries with Dates, Numbers.. but this as me puzzeled.
Andre