Change your Row Source to: SELECT "Buy And Sell" As Action FROM MAIN_QUERY UNION SELECT DISTINCT MAIN_QUERY.Action FROM MAIN_QUERY WHERE MAIN_QUERY.Action Is Not Null ORDER BY Action;
You might also need to write code in the AfterUpdate event of the combo box to examine the value of the combo box and filter the subform. If you're using this combo box as one of the Link Master Fields in the subform control, the new value "Buy and sell" is probably not a valid filter. John Viescas, author "Building Microsoft Access Applications" "Microsoft Office Access 2003 Inside Out" "Running Microsoft Access 2000" "SQL Queries for Mere Mortals" http://www.viescas.com/ -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of DHANANJAY Sent: Thursday, November 24, 2005 7:56 PM To: [email protected] Subject: [ms_access] Re: Execute different SQL query's base on combobox field Hi John, Thanks for update. I think in last mail I was not written clearly, sorry for misunderstanding. I will explain more. Query Name:- MAIN_QUERY Column Name :- Action I have one sub form under main form, when I select combobox fields on main form then acceding to that its show output on sub form. In my combo box currently there are two fields "Buy" or "Sellh as in action column there are only two fields. These fields I am calling using given query. gSELECT DISTINCT MAIN_QUERY.Action FROM MAIN_QUERY WHERE MAIN_QUERY.Action Is Not Null ORDER BY MAIN_QUERY.Action; h Problem is I can select only gBuyh or gSellh but I want to add one more field like gBuy and Sellh and when I select gBuy and Sellh then I should show gBuyh and gSellh output together. I hope It will clear. Still if you have any comments then let me know. Regards, Dhananjay Awachat --- In [email protected], "John Viescas" <[EMAIL PROTECTED]> wrote: > > When you say "execute", I assume you mean an "action" query - update, > append, delete, make table. Let's say the name of the query is in the bound > column of the combo box, and the name of the combo box is cmbQuerySelect. > You could execute the query in code behind a command button on the form like > this: > > Dim db As DAO.Database > > Set db = DBEngine(0)(0) > db.Execute Me.cmbQuerySelect, dbFailOnError > > John Viescas, author > "Building Microsoft Access Applications" > "Microsoft Office Access 2003 Inside Out" > "Running Microsoft Access 2000" > "SQL Queries for Mere Mortals" > http://www.viescas.com/ > > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf > Of DHANANJAY > Sent: Thursday, November 24, 2005 2:32 AM > To: [email protected] > Subject: [ms_access] Execute different SQL query's base on combobox field > > Hi Access Group, > > I am just started learning VBA code. I am doing one program where I have to > execute different SQL queryfs base on combobox field selection. > If any one knows how to do it then please let me know example. > > Regards, > Dhananjay Awachat > > > > > > > ------------------------ Yahoo! Groups Sponsor -------------------- ~--> > 1.2 million kids a year are victims of human trafficking. Stop slavery. > http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/q7folB/TM > -------------------------------------------------------------------- ~-> > > > Yahoo! Groups Links > ------------------------ Yahoo! Groups Sponsor --------------------~--> Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page http://us.click.yahoo.com/dpRU5A/wUILAA/yQLSAA/q7folB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> 1.2 million kids a year are victims of human trafficking. Stop slavery. http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/q7folB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/ms_access/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
