A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Use combo box to set parameter for query



 
 
Thread Tools Display Modes
  #1  
Old November 20th, 2006, 03:31 AM posted to microsoft.public.access.queries
Joanna
external usenet poster
 
Posts: 61
Default Use combo box to set parameter for query

I know how to create a parameter query, but is it possible to get the dialog
box that it invokes to display a drop-down list of potential values instead
of requiring the user to type in a value off the top of their head? ...maybe
get the values from existing entries in the underlying table or something?
Is this crossing the line into VBA?? Thanks.
  #2  
Old November 20th, 2006, 03:53 AM posted to microsoft.public.access.queries
John Vinson
external usenet poster
 
Posts: 4,033
Default Use combo box to set parameter for query

On Sun, 19 Nov 2006 19:31:01 -0800, Joanna
wrote:

I know how to create a parameter query, but is it possible to get the dialog
box that it invokes to display a drop-down list of potential values instead
of requiring the user to type in a value off the top of their head? ...maybe
get the values from existing entries in the underlying table or something?
Is this crossing the line into VBA?? Thanks.


You can do this pretty easily.

Create a little unbound form, let's call it frmCrit.

Put a Combo Box on it using as rowsource the list of values that you
want the user to have available for selection. This will typically be
a Query sorted appropriately; the bound column will be the field to be
searched for, which need not be the *visible* column of the combo. For
instance, you might have a Customers table with a CustomerID,
lastname, firstname, etc.; you could have CustomerID as the bound
column but Lastname, Firstname as the first visible column. Let's call
this combo box cboCrit.

Use a query criterion of

=[Forms]![frmCrit]![cboCrit]

It's convenient to put a command button on frmCrit (using the wizard)
to open a Report or Form based on the query; it is rarely or never
appropriate to open the query datasheet directly.

John W. Vinson[MVP]
  #3  
Old November 21st, 2006, 11:33 PM posted to microsoft.public.access.queries
Joanna
external usenet poster
 
Posts: 61
Default Use combo box to set parameter for query

Thanks! I guess I was so bent on the idea of changing the existing dialog
that I didn't consider this angle.

"John Vinson" wrote:

On Sun, 19 Nov 2006 19:31:01 -0800, Joanna
wrote:

I know how to create a parameter query, but is it possible to get the dialog
box that it invokes to display a drop-down list of potential values instead
of requiring the user to type in a value off the top of their head? ...maybe
get the values from existing entries in the underlying table or something?
Is this crossing the line into VBA?? Thanks.


You can do this pretty easily.

Create a little unbound form, let's call it frmCrit.

Put a Combo Box on it using as rowsource the list of values that you
want the user to have available for selection. This will typically be
a Query sorted appropriately; the bound column will be the field to be
searched for, which need not be the *visible* column of the combo. For
instance, you might have a Customers table with a CustomerID,
lastname, firstname, etc.; you could have CustomerID as the bound
column but Lastname, Firstname as the first visible column. Let's call
this combo box cboCrit.

Use a query criterion of

=[Forms]![frmCrit]![cboCrit]

It's convenient to put a command button on frmCrit (using the wizard)
to open a Report or Form based on the query; it is rarely or never
appropriate to open the query datasheet directly.

John W. Vinson[MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.