Selection in Combobox will not automatically show records in Subform. help!

leahb747

Registered User.
Local time
Today, 19:01
Joined
Jun 12, 2012
Messages
30
Hi all,
I'm relatively new to Access and need a little help with a combobox and subform.
My form is called Contact Register. The form contains a combobox that has two columns showing the Company Name and Division and a subform that I want to show the Contact details of each person relating to that Company Name and Division. I have set the Link Master and Child Fields to be Company ID and Division ID.
I have two problems.
1. When I select a Company and Division from the combobox, the record in the contact register does not change to display the correct Company and Division IDs. i have to go to the bottom of the main for and scroll across (eg I have three companies entered and I have to scroll across to number three to get the correct info). I want to pick a Company from the drop down and my subform automatically changes to the correct record.
2. The Company ID and Division ID (both of which are included kn the subform do not display in the underlying Contact Register table.

If anyone could help it would be greatly appreciated!

Leah
 
Re your first issue, one way to get the subform to link with the combo box pick is to use the following code in the After Update event of the combo:

Code:
' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[FieldYouAreLinkingOn] = '" & Me![cboNameOfYourCombo] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
I don't understand what you're doing with your Master/Child linking. This would normally be the Primary Key and the Foreign Key. CompanyID and DivisionID sound like two different fields.

Also, make sure that your table one to many relationship is defined as well.
 

Users who are viewing this thread

Back
Top Bottom