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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Passing value from combobox to query?



 
 
Thread Tools Display Modes
  #1  
Old April 12th, 2006, 12:58 PM posted to microsoft.public.access.forms,microsoft.public.access.formscoding
external usenet poster
 
Posts: n/a
Default Passing value from combobox to query?

Some simple things can make big problems. I can not make combobox work as it
should. Please help.

I have two comboboxes on form. Choice in combobox 1 should be criteria for
filtering data in query (on which combobox 2 is based). What could be the
sintax for passing data to query in design view in field criteria, or in
SQL view? Is it possible to make it with some public variable, which value
would be used in query. What would look like syntax in field criteria for
calling that value?
Thanks in advance.

Best regards,
Stosic Dejan.


  #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

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax for nulls in query MeredithS Setting Up & Running Reports 10 April 2nd, 2006 02:42 AM
creteria macros sierralightfoot Running & Setting Up Queries 13 March 8th, 2006 07:13 AM
Error when running Query, but not Report Blaze Running & Setting Up Queries 29 September 9th, 2005 05:40 AM
Big number gives error! Sara Mellen Running & Setting Up Queries 8 October 11th, 2004 02:48 AM
Print Taher Setting Up & Running Reports 1 August 31st, 2004 09:07 PM


All times are GMT +1. The time now is 06:11 AM.


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