3

I would like to know if there is a way without using loop to get multiply results from database using array?

Lets assume that we got this array:

Dim A As Variant
myUserName  = Array("AAA", "BBB", "CCC")

I want to know if there is a way to pass the array like that:

mySQLst = "SELECT * FROM UserTb WHERE (((UserTb.Nickname)='" & myUserName & "'));"

and get back all users who in the database answer the strings in ther array. I use Access database and Excel vba for this.

thank you for help.

1 Answer 1

2

You can use Join:

myUserName  = Array("AAA", "BBB", "CCC")
mySQLst = "SELECT * FROM UserTb WHERE UserTb.Nickname IN ('" & Join(myUserName, "','") & "');"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.