passing a parameter from VBA into a SQL-Query

J

jokobe

hi ng,

guess this is a simple question.

I have a username stored in a VBA variable called
local_user.
Now I want to start a SQL query
SELECT * FROM our_user WHERE username = local_user.

How can I pass this variable into the query, maybe with
a parameter???


Thanks in advance

jokobe
 
A

Allen Browne

Use a function to return the contents of the variable:

Public Function GetLocalUser() As String
GetLocalUser = local_user
End Function

SELECT * FROM our_user WHERE username = GetLocalUser();
 

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