how to open a subform to match parent record (1 Viewer)

martinr

Registered User.
Local time
Tomorrow, 09:11
Joined
Nov 16, 2011
Messages
73
i have a subform linked to it's parent form (linked via Master/Child fields) so when a surname is selected using a Combobox on the parent form only the matching records are listed in subform.



this works Ok except the whenever time the main form is opened the subform doesn't match the record in the combobox in parent form (ie parent form surname = ALLAN, subform surname = JONES).



the parent form's recordsource is a simple query and the combobox rowsource is also a query and is set to the load the first value (itemdata = 0)


how can i get the subform records to match the parent form when they load?
 

GinaWhipp

AWF VIP
Local time
Today, 18:11
Joined
Jun 21, 2011
Messages
5,901
Hmm, something is off. You say the Main Form and the Subform are linked. What field are they linked on?
 

martinr

Registered User.
Local time
Tomorrow, 09:11
Joined
Nov 16, 2011
Messages
73
hi Gina,
they are linked on the surname field;

link master field = surname
link child field = surname


the linking works fine once the parent form record is updated - it's only when the form
is first opened that they don't match.
thank-you...
 

GinaWhipp

AWF VIP
Local time
Today, 18:11
Joined
Jun 21, 2011
Messages
5,901
Umm, so the link doesn't work because two entities can have the same Surname. That might very well be why you are having a problem. Isn't there a Primary Key you can link on?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:11
Joined
Feb 19, 2002
Messages
42,976
Even with a very small population, won't you run into a problem with using surname to connect people? You really should be using an autonumber. Have one person designated as Head of Household and connect everyone else to that person.

As to your initial display problem, are you sure you don't have code behind the form that is causing the problem? For starters, you shouldn't be setting a value for the search combo. Just let it be. If your mainform query references the combo, then the form will open "empty" and that is fine. It prevents people from accidentally typing over the first record.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:11
Joined
May 7, 2009
Messages
19,169
the Link Master Fields should be the name of the combobox.
 

Users who are viewing this thread

Top Bottom