Open corresponding record in Subform (1 Viewer)

alanij

Registered User.
Local time
Today, 23:14
Joined
Nov 20, 2008
Messages
12
Hi

I am wondering if it is possible to open a subform via a command button to display the corresponding record in the Main form. I currently have a 1:1 relationship on Unique ID in both main form and subform. At the moment my command button opens up the subform ok but it doesn`t automatically display the corresponding record i have displayed in my main form.

1:1 relationships fields as follows:-
Main form ID Field = [ICF_Case ID Number]
Subform ID Field = [F1_Case ID Number]

Any help gratefully received.


thanks
 

DevastatioN

Registered User.
Local time
Today, 19:14
Joined
Nov 21, 2007
Messages
242
On the subform make sure that the Master/Child link fields are set correctly.

The Master Link Field should be "ICF_Case ID Number" and the Child Link Field should be "F1_Case ID Number".

This way when you display the subform, it should show the record in the subform where both of those numbers are identical.
 

alanij

Registered User.
Local time
Today, 23:14
Joined
Nov 20, 2008
Messages
12
Thanks for replying.

I have checked these and they are set up as you described. However, i still do not get the corresponding ID show when i click on the command button to display the subform. I have to scroll through the records to find the subform where the unique IDs match.
 

missinglinq

AWF VIP
Local time
Today, 18:14
Joined
Jun 20, 2003
Messages
6,420
A couple of questions:

If it's a 1:1 relationship, why are you using a form/subform, presumably with different tables holding the data? Form/Subform scenarios normally involve 1:Many relationships.

What code are you using to "open" the subform? A subform normally loads along with the main form, that's when Access makes the connection between the two. IF you don't want the subform visible when the main form opens, you can set the subform control's Visible Property to No, then use the button to set it to Yes.
 

DevastatioN

Registered User.
Local time
Today, 19:14
Joined
Nov 21, 2007
Messages
242
As missingling said, that is the correct way to "open" a subform. I guess I sort of accidentally assumed that you were doing it this way.

Attached is a copy of a database that demonstrates how the subform "opens" with a one to one relationship.
 

Attachments

  • openSub.zip
    23.1 KB · Views: 120

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:14
Joined
Sep 12, 2006
Messages
15,738
yes, this isnt right

the subform is functionally dependent on the main form - ie the subform just shows thos items that relate to the main form

so it just isnt possible to select something in the subform that doesnt relate to the active main form record?

so when you say subform/mainform can you clarify what you are really doing

-----------
do you mean you want some technique to find the main record that WOULD relate to a particular subform record - in that case you have to do a couple of steps in code

a) do a search/dlookup/find in code etc to find the subform record you want, and read the fk field which ideltifies the main form record
b) navigate to that fk in the mainform
c) and the subform should update automatically
 

Users who are viewing this thread

Top Bottom