Combo Box on Msg Box VBA

QandAdam

New Member
Joined
Jan 12, 2019
Messages
30
I have a button which shows a Pop-Up Box asking the user to enter a name of a staff member. Is it possible to edit the Pop-Up so that instead of showing a free text box (where the user can enter anything), it shows a combo box instead which lists the staff names?

If it helps, I currently have a query with all current staff listed. (qryCurrentStaff)

At the moment the VBA just runs an update query and an "Enter Parameter Value" box appears to complete the missing criteria. It's a bit of a dirty way of doing things but it was the easiest when creating it.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
A form button can run a query simply by using DoCmd.OpenQuery() as the code which runs when the button is clicked.
 
Upvote 0
I have this button currently. Here's a breakdown of what the current set up is like:

Form Button:
Code:
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAllocateBatch"
DoCmd.SetWarnings True

qryAllocateBatch:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Field[/TD]
[TD]Update To[/TD]
[TD]Criteria[/TD]
[/TR]
[TR]
[TD]StaffName[/TD]
[TD][ENTER STAFF NAME][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Batch[/TD]
[TD][/TD]
[TD][ENTER BATCH ID][/TD]
[/TR]
</tbody>[/TABLE]

When the user clicks on the button, the Enter Parameter Value Box appears asking the user to [ENTER STAFF NAME] and [ENTER BACTH ID] without them actually going into the query.

What I'm after is for the 'Enter Parameter Value' Box to display a combo box instead of free text to avoid the user spelling names incorrectly. (Or for a Msg Box to appear and do the same thing)

Does this help clear things up?
 
Last edited:
Upvote 0
You want the combo box to be on the form before the button is clicked. I.e. 1) Choose the value(s) from the list(s). 2) Then click the button. You can't literally have the query display a combo box (it can only display the enter parameter dialog, which is what you have now).
 
Upvote 0
You want the combo box to be on the form before the button is clicked. I.e. 1) Choose the value(s) from the list(s). 2) Then click the button. You can't literally have the query display a combo box (it can only display the enter parameter dialog, which is what you have now).

Ok, for the Form - I'm struggling to get my head around it (sorry!)

  • What would the Record Source of the Form be? I'm not able to select the current query because it's an update query.
  • What vba do I need to ensure the "Staff Name" and "Batch" Fields link to the Query fields?
 
Upvote 0
Change the UPDATE query to take the parameters from a form.

The form itself would be unbound but would you would set the row source of the combobox on the form to a query that returns the current staff, e.g. qryCurrentStaff.
 
Upvote 0
As mentioned, have unbound controls that have 'built in' queries as source. One for the Staff Name and possibly one for the batch ID.?
Change the query to use the controls from the form. Use the builder to get the correct syntax.
Have a button to run the query as you have now. The query will take it's parameters from the form and run as it used to.?

HTH
 
Upvote 0

Forum statistics

Threads
1,223,704
Messages
6,173,984
Members
452,540
Latest member
haasro02

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top