Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put results of a query in a drop down list

Status
Not open for further replies.

t16turbo

Programmer
Mar 22, 2005
315
GB
Hello,

I have a query on a worksheet named "Managers"
this returns a single column of project managers.

I need to put the results of this in a drop down for people to select.
this will then get passed into another query.

Also, The list will need refreshing when the Spreadsheet opens.

any ideas?
thanks in advance..
 
set the query to run on file open (one of the properties of the data table)

set up a dynamic named range to hold the returned results

Reference this named range in Data>Validation to create your dropdown list

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
I have now created the list box and, with your help, define the named range.

I have a command button which, when clicked, calls my Module1 code and passes in the value of the listbox.

this is where I am having an error.

my code on the sheet with the list box and command button is:
Code:
Private Sub CommandButton1_Click()

ManagerName = ListBox1.Value

Call AutoFOB(ManagerName)

End Sub

when I click this, I get the error "Wrong number of arguments"
I'm not sure why this is..
do you know?
 
I ain't psychic so I guess I would need to know whether AutoFOB requires a parameter to be passed to it ??

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
you're not?! ;-)

AutoFob does have a variable in it, that was originally obtained via a FOR loop on a range of data.

What the problem turned out to be was the listbox value going straight into the 'Call' argument.

Instead I included a textbox, and in the ListBox1_Click() behaviour set the text box.

then in the command button I just pass the value of the textbox into the main Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top