PC Review


Reply
Thread Tools Rate Thread

Feed Combo Box with a Query

 
 
Alejandro
Guest
Posts: n/a
 
      22nd Dec 2009
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.
 
Reply With Quote
 
 
 
 
ph
Guest
Posts: n/a
 
      22nd Dec 2009
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rss feed loads on startup outlook how to remove the feed? nambet Microsoft Outlook Discussion 1 10th May 2009 08:10 PM
HELP !! Combo box to feed other combo boxes Flanders Microsoft Access Form Coding 5 18th Dec 2007 04:27 PM
RSS Feed Folder renamed & feed directed to it =?Utf-8?B?QW5keSBTY2hhbg==?= Microsoft Outlook Discussion 0 14th Oct 2006 03:28 PM
Re: how to feed result from P_T query to combo box? Duane Hookom Microsoft Access Queries 0 13th Sep 2005 07:30 PM
utilizing both pin feed and sheet feed printer Keith Windows XP Print / Fax 0 30th Oct 2003 09:31 PM


Features
 

Advertising
 

Newsgroups
 


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