passing a parameter from VBA into a SQL-Query

  • Thread starter Thread starter jokobe
  • Start date Start date
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
 
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();
 
Back
Top