Linked Forms Unlike Form/Subforms in Not Passing Primary Key Value

A

Access Non-Pro

Why won't linked forms work like subforms embedded in main forms? When a
primary key value (e.g., client I.D.) is entered on a main form, the value is
passed to an embedded subform. However, when a primary key value is entered
on the main form and the subform is only linked (and synchronized), the value
is not passed. Once the value is manually entered, the two linked forms work
together like a form/subform. But, I must have that primary key value
automatically entered in the linked subform.

What must I do to make linked forms work like embedded forms? Thanks.
 
B

Beetle

To get the linked subform to only display records that are related to the
selected record in the Main form, pass the value in the Click event of
the command button on your Main form;

Private Sub cmdYourButton_Click ()

DoCmd.OpenForm "frmYourSubForm", , , "ClientID = " & Me!ClientID

End Sub


The above assumes ClientID is a number data type.

To get the subform to insert the correct ClientID when you create new
records in the *subform*, pass the value in the Before Insert event
of the *subform*

Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub
 
A

Access Non-Pro

Putting that code in the Before Insert property slot of the subform didn't
work -- nor did putting it in the filter property slot for the subform. What
property does the embedded subform have that the linked subform does not?

Here is the exact code I used, in case I missed something obvious:
"[Referral Information_HSIS Number]=[Forms]![IC Tracking Form]![HSIS Number]"

Thank you.

____________________________________________________________
 
M

M Skabialka

Have you tried setting the control source for the linked form to have a
parameter in the query saying the field on the linked form must match the
value on the main form?

Access Non-Pro said:
Putting that code in the Before Insert property slot of the subform didn't
work -- nor did putting it in the filter property slot for the subform.
What
property does the embedded subform have that the linked subform does not?

Here is the exact code I used, in case I missed something obvious:
"[Referral Information_HSIS Number]=[Forms]![IC Tracking Form]![HSIS
Number]"

Thank you.

____________________________________________________________

Beetle said:
To get the linked subform to only display records that are related to the
selected record in the Main form, pass the value in the Click event of
the command button on your Main form;

Private Sub cmdYourButton_Click ()

DoCmd.OpenForm "frmYourSubForm", , , "ClientID = " & Me!ClientID

End Sub


The above assumes ClientID is a number data type.

To get the subform to insert the correct ClientID when you create new
records in the *subform*, pass the value in the Before Insert event
of the *subform*

Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub
 
B

Beetle

Guess I should have been more specific.

You don't enter the code directly in the property line. You need to click the
build (...) button at the right end of the line, then select Code Builder. The
code window will open with the following lines already displayed;

Private Sub Form_BeforeInsert (Cancel As Integer)

End Sub

Then you would put the code between those two lines, so the end result
would look like;


Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


Access Non-Pro said:
Putting that code in the Before Insert property slot of the subform didn't
work -- nor did putting it in the filter property slot for the subform. What
property does the embedded subform have that the linked subform does not?

Here is the exact code I used, in case I missed something obvious:
"[Referral Information_HSIS Number]=[Forms]![IC Tracking Form]![HSIS Number]"

Thank you.

____________________________________________________________

Beetle said:
To get the linked subform to only display records that are related to the
selected record in the Main form, pass the value in the Click event of
the command button on your Main form;

Private Sub cmdYourButton_Click ()

DoCmd.OpenForm "frmYourSubForm", , , "ClientID = " & Me!ClientID

End Sub


The above assumes ClientID is a number data type.

To get the subform to insert the correct ClientID when you create new
records in the *subform*, pass the value in the Before Insert event
of the *subform*

Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub
 
A

Access Non-Pro

Thanks for the reply, but you'll have to become even more specific. I can't
find any reference to "Code Builder" in the Expression Builder. Please don't
omit any details. I am not a programmer. Thanks much.
_____________________________________________

Beetle said:
Guess I should have been more specific.

You don't enter the code directly in the property line. You need to click the
build (...) button at the right end of the line, then select Code Builder. The
code window will open with the following lines already displayed;

Private Sub Form_BeforeInsert (Cancel As Integer)

End Sub

Then you would put the code between those two lines, so the end result
would look like;


Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


Access Non-Pro said:
Putting that code in the Before Insert property slot of the subform didn't
work -- nor did putting it in the filter property slot for the subform. What
property does the embedded subform have that the linked subform does not?

Here is the exact code I used, in case I missed something obvious:
"[Referral Information_HSIS Number]=[Forms]![IC Tracking Form]![HSIS Number]"

Thank you.

____________________________________________________________

Beetle said:
To get the linked subform to only display records that are related to the
selected record in the Main form, pass the value in the Click event of
the command button on your Main form;

Private Sub cmdYourButton_Click ()

DoCmd.OpenForm "frmYourSubForm", , , "ClientID = " & Me!ClientID

End Sub


The above assumes ClientID is a number data type.

To get the subform to insert the correct ClientID when you create new
records in the *subform*, pass the value in the Before Insert event
of the *subform*

Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


:

Why won't linked forms work like subforms embedded in main forms? When a
primary key value (e.g., client I.D.) is entered on a main form, the value is
passed to an embedded subform. However, when a primary key value is entered
on the main form and the subform is only linked (and synchronized), the value
is not passed. Once the value is manually entered, the two linked forms work
together like a form/subform. But, I must have that primary key value
automatically entered in the linked subform.

What must I do to make linked forms work like embedded forms? Thanks.
 
A

Access Non-Pro

I got the Code Builder window to come up. Does this code require "ClientID"
to be numeric? It's presently text. Thanks.

____________________________________

Access Non-Pro said:
Thanks for the reply, but you'll have to become even more specific. I can't
find any reference to "Code Builder" in the Expression Builder. Please don't
omit any details. I am not a programmer. Thanks much.
_____________________________________________

Beetle said:
Guess I should have been more specific.

You don't enter the code directly in the property line. You need to click the
build (...) button at the right end of the line, then select Code Builder. The
code window will open with the following lines already displayed;

Private Sub Form_BeforeInsert (Cancel As Integer)

End Sub

Then you would put the code between those two lines, so the end result
would look like;


Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


Access Non-Pro said:
Putting that code in the Before Insert property slot of the subform didn't
work -- nor did putting it in the filter property slot for the subform. What
property does the embedded subform have that the linked subform does not?

Here is the exact code I used, in case I missed something obvious:
"[Referral Information_HSIS Number]=[Forms]![IC Tracking Form]![HSIS Number]"

Thank you.

____________________________________________________________

:

To get the linked subform to only display records that are related to the
selected record in the Main form, pass the value in the Click event of
the command button on your Main form;

Private Sub cmdYourButton_Click ()

DoCmd.OpenForm "frmYourSubForm", , , "ClientID = " & Me!ClientID

End Sub


The above assumes ClientID is a number data type.

To get the subform to insert the correct ClientID when you create new
records in the *subform*, pass the value in the Before Insert event
of the *subform*

Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


:

Why won't linked forms work like subforms embedded in main forms? When a
primary key value (e.g., client I.D.) is entered on a main form, the value is
passed to an embedded subform. However, when a primary key value is entered
on the main form and the subform is only linked (and synchronized), the value
is not passed. Once the value is manually entered, the two linked forms work
together like a form/subform. But, I must have that primary key value
automatically entered in the linked subform.

What must I do to make linked forms work like embedded forms? Thanks.
 
A

Access Non-Pro

Someone please help. This scheme is not working. Is there another way to
make a subform linked to a form display the Client ID entered on the main
form without having to enter it manually on the subform? Thank you.

______________________________________________

Access Non-Pro said:
I got the Code Builder window to come up. Does this code require "ClientID"
to be numeric? It's presently text. Thanks.

____________________________________

Access Non-Pro said:
Thanks for the reply, but you'll have to become even more specific. I can't
find any reference to "Code Builder" in the Expression Builder. Please don't
omit any details. I am not a programmer. Thanks much.
_____________________________________________

Beetle said:
Guess I should have been more specific.

You don't enter the code directly in the property line. You need to click the
build (...) button at the right end of the line, then select Code Builder. The
code window will open with the following lines already displayed;

Private Sub Form_BeforeInsert (Cancel As Integer)

End Sub

Then you would put the code between those two lines, so the end result
would look like;


Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


:


Putting that code in the Before Insert property slot of the subform didn't
work -- nor did putting it in the filter property slot for the subform. What
property does the embedded subform have that the linked subform does not?

Here is the exact code I used, in case I missed something obvious:
"[Referral Information_HSIS Number]=[Forms]![IC Tracking Form]![HSIS Number]"

Thank you.

____________________________________________________________

:

To get the linked subform to only display records that are related to the
selected record in the Main form, pass the value in the Click event of
the command button on your Main form;

Private Sub cmdYourButton_Click ()

DoCmd.OpenForm "frmYourSubForm", , , "ClientID = " & Me!ClientID

End Sub


The above assumes ClientID is a number data type.

To get the subform to insert the correct ClientID when you create new
records in the *subform*, pass the value in the Before Insert event
of the *subform*

Private Sub Form_BeforeInsert (Cancel As Integer)

Me!ClientID = Forms!YourMainForm!ClientID

End Sub

--
_________

Sean Bailey


:

Why won't linked forms work like subforms embedded in main forms? When a
primary key value (e.g., client I.D.) is entered on a main form, the value is
passed to an embedded subform. However, when a primary key value is entered
on the main form and the subform is only linked (and synchronized), the value
is not passed. Once the value is manually entered, the two linked forms work
together like a form/subform. But, I must have that primary key value
automatically entered in the linked subform.

What must I do to make linked forms work like embedded forms? Thanks.
 
A

Access Non-Pro

Thanks, Rick! That's the answer I was looking for - just what was needed
without complicating things more than necessary.

Non-Pro
____________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top