View Single Post
  #2  
Old April 12th, 2006, 03:20 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
external usenet poster
 
Posts: n/a
Default Passing value from combobox to query?

Hi Stosic,

To have a combo box show a list based on another combo box try the
following:

Consider two combo boxes called cbx_one and cbx_two

in cbx_one under properties, under row source, enter your sql text as
normal to query one of your tables e.g.

SELECT [tbl_Demo].[ID], [tbl_Demo].[Forename] FROM tbl_Demo;

This basically says show the ID field and Name field from the Table
called Demo.....pretty straight forward.(Always make sure the ID is
included as this is used in the second combo box).


Then you need to create a query and insert the required fields that you
want to show in the second combo box remebering to include the ID
placed in the the first combo box [Hope this makes sense!].

Then in cbx_two under properties under row source, try the following:

SELECT [qry_Demo].[Surname] FROM qry_Demo WHERE
((([qry_Demo].[ID])=[Forms]![frm_Demo]![cbx_One])) ORDER BY
[qry_Demo].[Surname];


Just change all text in the [] brackets to what is relevant in your
database and all should work fine!!

Hope this makes sense and helps, it definately works! ;o)

Regards
Housemate