Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Generate a report from SQL to Excel using a ListBox

Generate a report from SQL to Excel using a ListBox

Generate a report from SQL to Excel using a ListBox


I am pulling a report from SQL in Excel. I got it all working, except I need multiple user prompts (one parameter with multiple values).

So I decided to use a listbox which contains all the possible selection that I want the user to choose from (These values are on another sheet in the same workbook) and then when a button is clicked, it displays the information in that same worksheet base on the selected choices the user choose.

This information that is being displayed is coming straight from SQL.

I tried using a userform in VBA in Excel, but I am still not quite sure how to have it pull from SQL base on the selections in the listbox.

I had it where the information was displayed, except I was only able to input one parameter at a time. I want the user to be able to do multiple selections and then the information is displayed.

In my query I had wmav_code = ? to prompt the user to input what code they wanted, bus as stated before, its just one. I tried wmav_code in (?,?,?,?), however, that's limiting the prompts to 4. I have 97 various codes to choose from (Hence the decision to use a listbox).

I tried (InStr(?, [wmav_code])>0), but Excel 2016 does not recognize that function (InStr()).

P.S. These are all within the 'WHERE' clause.

Any help is appreciated!!! :)

Thank you!

RE: Generate a report from SQL to Excel using a ListBox


This is an MS Excel question, not a MySQL question. This question is related to how Excel handles Parameters in MS Query. It normally would be best addressed in forum68: Microsoft: Office.

HOWEVER, since this requirement exceeds Excel's query parameter features, it would be better to post your qustion in forum707: VBA Visual Basic for Applications (Microsoft), since it will requite custom VBA macro code.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close