Feed Combo Box with a Query

Hello everyone,

I have a form that among other things has two combo boxes. The first one is 
fed with a simple table with two entries. I would like the second one to 
display the result of a query run in the background. The idea is that based 
on what the user selects in the first combo box she would get a specific set 
of options in the second one.

I don't know if this is the right way to do it, but if anything else at 
least the following code will give you an idea of what I'm trying to do:

Private Sub cmb_FirstComboBox_AfterUpdate()

Dim SQL As String

If Me.cmb_FirstComboBox = "Front Desk" Then

    SQL = "SELECT DISTINCT [FD REP] FROM tbl_MasterTable" & _
    "ORDER BY tbl_MasterTable.[fd rep]"

ElseIf Me.cmb_FirstComboBox = "Back Office" Then
    SQL = "SELECT DISTINCT [adm rep] FROM tbl_MasterTable" & _
    "ORDER BY tbl_MasterTable.[adm rep]"

DoCmd.RunSQL SQL

End If

(and this point I would have something that links the cmb_SecondComboBox 
with the results of the SQL query)

Could anyone give me a hand with this, please?

Thanks,

A.
0
Utf
12/22/2009 12:04:03 AM
access.modulesdaovba 1670 articles. 0 followers. Follow

1 Replies
634 Views

Similar Articles

[PageSpeed] 59

and if you replace :  DoCmd.RunSQL SQL
by :
 Me.cmb_SecondComboBox .Rowsource = SQL 



"Alejandro" wrote:

> Hello everyone,
> 
> I have a form that among other things has two combo boxes. The first one is 
> fed with a simple table with two entries. I would like the second one to 
> display the result of a query run in the background. The idea is that based 
> on what the user selects in the first combo box she would get a specific set 
> of options in the second one.
> 
> I don't know if this is the right way to do it, but if anything else at 
> least the following code will give you an idea of what I'm trying to do:
> 
> Private Sub cmb_FirstComboBox_AfterUpdate()
> 
> Dim SQL As String
> 
> If Me.cmb_FirstComboBox = "Front Desk" Then
> 
>     SQL = "SELECT DISTINCT [FD REP] FROM tbl_MasterTable" & _
>     "ORDER BY tbl_MasterTable.[fd rep]"
> 
> ElseIf Me.cmb_FirstComboBox = "Back Office" Then
>     SQL = "SELECT DISTINCT [adm rep] FROM tbl_MasterTable" & _
>     "ORDER BY tbl_MasterTable.[adm rep]"
> 
> DoCmd.RunSQL SQL
> 
> End If
> 
> (and this point I would have something that links the cmb_SecondComboBox 
> with the results of the SQL query)
> 
> Could anyone give me a hand with this, please?
> 
> Thanks,
> 
> A.
0
Utf
12/22/2009 12:36:02 PM
Reply:

Similar Artilces:

Access Query result different when opened in automation
I have a query that pulls information from three different linked tables. (this might very well be the source of my problems but I dont understand why) When I run the query manually in Access the result set is as I expect, but when I use that query in a function in Access VBA, the where clause is partially ignored. The part that is ignored is here: (ServerDetails.SERVER_TYPE) Not Like "*Domain Controller*") The full filter is here: WHERE (((ServerDetails.ENVIRONMENT)="HOME") AND ((ServerDetails.SERVER_TYPE) Not Like "*Domain Controller*") AND (((ServerDet...

RSS Feed List only displays three feeds
I'm using Outlook 2007 for a month now and imported a list of RSS/ATOM feeds. I'm still using my old feed reader in parallel and noticed that since about a week most of the feeds were not updated in Outlook. I opened the send/receive settings to see what's included when doing a send/receive and found that only three feeds were displayed. They worked but all of the other did not. I then created a new group named "RSS feeds" and included the three listed feeds. After several send/receive on this group, I finally received messages from other blogs as well. The settin...

combo boxes and lookup
Hello I'm trying to get some data to be synchronised with some data in a combo boxes, (e.g. when I select an item from the combo box I want the correct value/answer for it to be displayed in one of the cells). Plz help as I'm pretty new to all of this. for a combobox from the control toolbox toolbar, Link the combobox to the cell where you want the value to appear. Right click on the combobox in design mode and select properties. Use the linked cell property with an argument like Sheet1!B9 -- Regards, Tom Ogilvy "Addz" <Addz@discussions.microsoft.com> wrote i...

Remove Box or Squre Characte from Cells
After doing an export from Outlook/Contacts to Excel I notice a square or box like character in all my cells. Is there an easy way to remove it, find and replace does not work. Thanks Chip Pearson has a very nice addin that will help determine what that character(s) is: http://www.cpearson.com/excel/CellView.htm If you do see a box, then you can either fix it via a helper cell or a macro: =substitute(a1,char(9),"") or =substitute(a1,char(9)," ") or as a macro (after using Chip's CellView addin): Option Explicit Sub cleanEmUp() Dim myBadChars As Variant ...

How to export a query to then xml-format file via VBA?
Hi. I would like to transfer my access query to xml-format, but how can I do it via VBA automatically? hanski ...

How to update query memo field
I have an old db that I need to import a long notes field from. My new table is existing. I have managed to get the notes from the old db into a comma separated text file with just an SSN and the notes. I can import this into a table that is structured with just an SSN field and a memo field. I'm trying to run an update query to fill in the notes fields of the people already in the new table. When I run the update query it says it's going to update x number of records, but doesn't. I tried changing both the old and new tables to text fields as an experiment and then it works, but o...

viewing emails in mail box
I have a security issue that demands review of another persons email box without their knowledge. I would like to view what is currently in their email box and monitor it for the next 30 days. I can use the forward to option to view future emails but not sure this is the best option and how do I view the current email box. We are using Exchange 2003 on Windows 2003. Journaling will do this. http://www.msexchange.org/tutorials/Implementing-Exchange-2003-Message-Journaling.html It works at the store level, but you can create a separate store and move only the user you want to journal t...

How to feed the contents of a cell as row index?
Hi, eg. if c5=3 a[c5] should give me the contents of a3 like in any high level language Excel does not treat a column as an array (table) so when C5=3, the formula =A[C5] means nothing. However, the formula =INDIRECT("A"&C5) will be equivalent to =A3 when C5 has value 3 best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "sudhakar" <sudhakar@discussions.microsoft.com> wrote in message news:CD83DC2E-7213-438E-A7CD-F3C5DC7463F4@microsoft.com... > Hi, > eg. if c5=3 > a[c5] should give me the contents of a3 li...

Question on Sorting within a query
Hello, I have 1 query which is the basis for a datasheet and a report. It seems that no matter what I specify in the ORDER BY clause, the sort order differs in the report and datasheet. Same thing results if I ORDER BY more than 1 column. It also seems that if I specify sorting by more than 1 column in design view, sorting only occurs on the first column. When I switch to SQL view, both columns do show up in the ORDER BY clause, but still only 1 column is sorting. Is there a bug of some sort that pops up when sorting query results? TIA, Rich A report completely ignores the OrderB...

News Feed Folders
I have just purchased office 2007 and use Outlook for my mail. I have a problem with my News Feed Folders as they seem to breed like rabbits and are now up to 20 for the third time. Is there any way to get rid of the NRF completely as I am fed up of them cluttering up my folder section. They are always empty so what is the point? Help pls pls pls :-) Norm Taylor wrote: > I have just purchased office 2007 and use Outlook for my mail. I have a > problem with my News Feed Folders as they seem to breed like rabbits and are > now up to 20 for the third time. Is there any...

How do I setup a cascading combo boxes?
I have a user form with 3 combo boxes that I would like to set up to narrow down information on a worksheet in the same workbook as the User Form. Can anyone help me or guide me on how to do it? Data in Worksheet -------------------------------- GEORGIA OFFICES CLLI NAME ADDRESS 1 ADDRESS 2 CITY STATE ZIP GLC Code T-Base Data is layed out across the worksheet. Data in Worksheet -------------------------------- Clli: ACWOGAMA Add 1: 4745 Logan Road City: Acworth St: GA Zip: 30101 GLC: F5341 Clli: AGSTGAAU Add 1: 3523 Washington Street City: Augu...

IMAP foler query
Hi, I would like to know how to set the save sent message copy to the IMAP server folder instead of the Local "Sent Items" ? I can set those kind of setting in the Outlook Express but I cannot find this option in the Microsoft Outlook 2002/2003 ? Anyone can help ? Thanks, Panda Panda wrote: > I would like to know how to set the save sent message copy to the IMAP > server folder instead of the Local "Sent Items" ? > > I can set those kind of setting in the Outlook Express but I cannot find > this option in the Microsoft Outlook 2002/2003 ? Agreed. ...

Combo Box #15
I have followed some examples but have not seen what I am looking for. If I have the following on a worksheet. How do I code or set up a combo box to show this text in combo box but when selected show the appropriate number code in the cell?. Employee Training/ASSE Lunch - 7040000 Business Meetings/Food/Personnel Costs - 7090000 Fee Service/Resources - 7110000 Postage - 7300000 Telephone/Cell - 7310000 Office Supplies ...

Switch maximize button in a title bar of a dialog box off
Hello, is there a possiblity to switch the maximize/ normalize button in a title bar of a dialog box off (and on) by using a method during program operation instead of not setting the SW_MAXIMIZEBOX option in Create ? What is the Windows-Message if a user presses the maximize button ? Is it possible to overwrite the message handler ? Which method is it ? Thanks in advance for your help. Greeting Alex > is there a possiblity to switch the maximize/ normalize button in a > title bar of a dialog box off (and on) by using a method during > program operation instead of not se...

Parameter Query 05-15-07
I am setting up a phone book I have set up the query [What Company] When I run the query and the Prompt Box asks for the company name, I cannot get it to produce any companies that I do not know the correct spelling for How can I get it to produce company names, Wildcards????? -- JohnM To get wild card in a query use Like + * In the criteria - ============== Like "*" & [What Company] & "*" will return the records that contain the string, any where ============== Like "*" & [What Company] will return the records that contain the string, in the...

Odd Drop Down Box Behavior
I have a drop down box on a spreadsheet in a workbook with several spreadsheets. For some reason the contents of the drop down box is beeing bled through to other spreadsheets in the exact same cell reference that the drop down box is linked to, replacing what may be in that cell. It happens randomly yet often, and I have not been able to discern any patterrn or catalyst. The contents and cell formatting are being transfered. It also happens on other spreadsheets using the drop down box. This is an Active-X box, not a forms box, using Excel 2007. Anybody seen this? Squeaky...

Print Preview from a modeless dialog box
Hello, I'm writing a dialog-based MFC application in VC++ 6.0 where one of the requirements is to provide the user with a print preview feature. The application has a main dialog window and the user has an option of generating a report, which is displayed as a modeless dialog window. The class that displays the modeless dialog report is located in another DLL. The user should be able to print and print preview the contents of the modeless dialog. I already implemented the printing by following the Code Project article "Printing without the Document/View framework" by Chris M...

Medium time text box shows year
I am working with an adp access frontend and a SQL Server backend. One of my forms uses several Medium Time fields with Input Mask: 99:00\ >LL;0;_ Default Value: #10:00:00 PM# (for example) The problem is that whenever I click on one of these fields the following year information shows, too, in addition to the time: "12/30/1899" The year information is also saved in the SQL Server table, e.g. "12/30/1899 10:00:00 PM" I only want to save the time, how do I get rid of the year? Thanks for your help. AFAIK, SQL Server doesn't have a time-only data type (I know Acces...

Outlook Client on CRM 1.2 Server Box for Demos
Hi, Did a CRM 1.2 install on Windows 2003 Server and all is working well. I have been seeing things on this newsgroup that say I should be able to install the Outlook client as well on this machine although it is an unsupported configuration. This is for demo's only. I am running it under Virtual PC. I would like to not have to have 2 Virtual PC images running just to show the Outlook integration to CRM. When I try to install the Outlook client I get a message at the start saying that the Outlook client is already installed. It is not. Suggestions anyone? Alan ...

Report Text box
I have a report that i would like to have some text with a delivery day that is from the query the reportis based on So i need a text box in the report somthing like below but it does not work = You parcel will be delivered on [DeliveryDay] at [Deliverytime] Please can somesone tell me how i edit the code to work Thanks SImon On Mon, 15 Oct 2007 11:12:08 -0700, Simon wrote: > I have a report that i would like to have some text with a delivery > day that is from the query the reportis based on > > So i need a text box in the report somthing like below but it does not > ...

Why are my RSS Feeds not updating
I have three Microsoft feeds, one is Microsoft At Home , one is Microsoft At Work and the last is MSNBC News. They are in my subscribed feeds list but do not update as they do on my desktop. Are they still listed as subscribed when you go to; Tools-> Account Settings...-> RSS Feeds If so, removing them and then adding them back might help to revive them. You can also export the RSS Feeds to an OPML file, remove the subscriptions and then import the OPML file again. For details see; http://www.msoutlook.info/question/406 -- Robert Sparnaaij [MVP-Outlook] Coauthor, C...

combo box 01-31-08
Thank you I have combo box Control Source= Row source type= table \query row source = SELECT tblClient.IDClient FROM tblClient; I want if the user type one of the IdClient in the combo box message box appear ("the number you type already exists" ) I don't get the point. If you'll creating the one as you stated below you're creating another table which same as your table source. and of course if you have a creating a source like below all the content of combo box were exist. I suggest you to make a primary key for the uniqueness of every record. a wrote: &g...

Query AD
Hy, there is some tools that i can use to query the active directory? I need to know if users are members of some groups or not. Thanks Kentucky On 21 Nov 2006 05:56:58 -0800, "Kentucky" <aforino@libero.it> wrote: >Hy, there is some tools that i can use to query the active directory? >I need to know if users are members of some groups or not. >Thanks >Kentucky ldp.exe (Windows Support Tools Download) adfind (you can google that) are two popular tools On 21 Nov 2006 05:56:58 -0800, "Kentucky" <aforino@libero.it> wrote: >Hy, there is some to...

Delete duplicates QUERY
I'm having two tables, each with one field which contains some data: ___________ Table1 Field1 Per Pert Perte Perter ___________ Table2 Field2 Pert ___________ Now, I want to make a DELETE Query in MS ACCESS 2003. I go by the "Find Unmatched Query Wizard" (1st point on Table2, 2nd point on Table1, 3rd click on Field2<=>Field1, 4rd point on Field2 to see. Then I have "Table2 Without Matching Table1" (I then change Is Null to <>"False" and show Table1.Field1 in stead of Table2.Field2)) I'll then end up with this SQL...

Maximize box with all windows
Hello. I have dialog box with few resourses (edit boxes, list boxes etc) and I added in properties of dialog box option : Maximize box. But when I try to do this (push square in right top corner) then maximize only main dialog box, but other reseourses like edit box and list boxes have orginal size. How to do that all components expand when I maximize dialog window ? ovverride the OnSize method and resize the controls per your desire ..... "Mammoth" <cactusek@gmail.com> wrote in message news:1171021945.301283.205810@p10g2000cwp.googlegroups.com... > Hello. > I have dia...