PC Review


Reply
Thread Tools Rate Thread

Combo box synchronization

 
 
Anne
Guest
Posts: n/a
 
      5th May 2010
Hello,
I have a database where I want to have an Events form that will track all
contacts and the Organization they work for. Several contacts can belong to
one Organization, so I have a MainContact and MainOrganization table. The
MainContact table includes first name, and last name as separate fields, as
well as an org_id field that is linked to the id field in MainOrganization.

I want the user to be able to select an organization and have all of the
names of contacts associated with that organization appear. I also want the
user to be able to select more than one contact for each organization.

Here is what I have set up so far in the Form Detail, and does not work:

Row Source for cboOrganization:
SELECT MainOrganization.id, MainOrganization.OrgName
FROM MainOrganization
ORDER BY MainOrganization.OrgName;

Row Source for cboMainContact:
SELECT MainContact.per_first_name, MainContact.per_last_name,
MainContact.org_id
FROM MainContact
ORDER BY MainContact.per_last_name;


After Update for cboOrganization: (this should look familiar; it's posted as
the cure in several places! That's not to say I used it incorrectly, though)
Private Sub cboOrganization_AfterUpdate()
' Update the row source of the cboContacts combo box
' when the user makes a selection in the cboOrganization
' combo box.
Me.cboContacts.RowSource = "SELECT per_first_name, per_last_name FROM" & _
" MainContact WHERE org_id = " & _
Me.cboOrganization & _
" ORDER BY per_last_name"

Me.cboOrganization = Me.cboOrganization.ItemData(0)
End Sub

At first, I could select an Organization and the correct contacts would
appear, but the Organization name would not stay in the combobox; regardless
of what organization was selected, the first one in the list would appear.

Secondly, I could not figure out how to select more than one contact.

Third, with the same information as above, I now get the following error:
“Syntax error (missing operator) in query expression ‘[org_id]=ACMC Granite
Falls Medical Clinic’

Fourth, absolutely nothing would happen if I left Row Source empty, or tried
to set it to only one field from each table.

Help!

Thanks.
Anne


 
Reply With Quote
 
 
 
 
Amy E. Baggott
Guest
Posts: n/a
 
      14th May 2010
If you want to select more than one contact, you'd be better off to use a
list box for your second combo. You can set the source to always use the
WHERE clause ("WHERE org_id = ' & me.cboOrganization). In the AfterUpdate
event of cboOrganization, put the command me.lstContacts.requery

This should work.
--
Amy E. Baggott

"I''m going crazy and I''m taking all of you with me!" -- Linda Grayson


"Anne" wrote:

> Hello,
> I have a database where I want to have an Events form that will track all
> contacts and the Organization they work for. Several contacts can belong to
> one Organization, so I have a MainContact and MainOrganization table. The
> MainContact table includes first name, and last name as separate fields, as
> well as an org_id field that is linked to the id field in MainOrganization.
>
> I want the user to be able to select an organization and have all of the
> names of contacts associated with that organization appear. I also want the
> user to be able to select more than one contact for each organization.
>
> Here is what I have set up so far in the Form Detail, and does not work:
>
> Row Source for cboOrganization:
> SELECT MainOrganization.id, MainOrganization.OrgName
> FROM MainOrganization
> ORDER BY MainOrganization.OrgName;
>
> Row Source for cboMainContact:
> SELECT MainContact.per_first_name, MainContact.per_last_name,
> MainContact.org_id
> FROM MainContact
> ORDER BY MainContact.per_last_name;
>
>
> After Update for cboOrganization: (this should look familiar; it's posted as
> the cure in several places! That's not to say I used it incorrectly, though)
> Private Sub cboOrganization_AfterUpdate()
> ' Update the row source of the cboContacts combo box
> ' when the user makes a selection in the cboOrganization
> ' combo box.
> Me.cboContacts.RowSource = "SELECT per_first_name, per_last_name FROM" & _
> " MainContact WHERE org_id = " & _
> Me.cboOrganization & _
> " ORDER BY per_last_name"
>
> Me.cboOrganization = Me.cboOrganization.ItemData(0)
> End Sub
>
> At first, I could select an Organization and the correct contacts would
> appear, but the Organization name would not stay in the combobox; regardless
> of what organization was selected, the first one in the list would appear.
>
> Secondly, I could not figure out how to select more than one contact.
>
> Third, with the same information as above, I now get the following error:
> “Syntax error (missing operator) in query expression ‘[org_id]=ACMC Granite
> Falls Medical Clinic’
>
> Fourth, absolutely nothing would happen if I left Row Source empty, or tried
> to set it to only one field from each table.
>
> Help!
>
> Thanks.
> Anne
>
>

 
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
Union Query and Combo Box Synchronization =?Utf-8?B?U2hhcm9u?= Microsoft Access Forms 1 13th Oct 2006 08:50 PM
C# Combo Box Synchronization =?Utf-8?B?c3VsbGlPaGlv?= Microsoft Dot NET 0 11th Sep 2006 03:21 PM
Combo Box Synchronization =?Utf-8?B?ODQ=?= Microsoft Access Form Coding 1 17th Aug 2005 09:47 PM
Multiple Combo Box Synchronization =?Utf-8?B?WmVkYmlrZXI=?= Microsoft Access Forms 0 22nd May 2005 07:53 PM
Combo box synchronization Scott Microsoft Access Forms 1 17th Aug 2004 02:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 PM.