Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LINKING RELATED FIELDS ON TWO FORMS

Status
Not open for further replies.

baybie

IS-IT--Management
Oct 5, 2002
68
GB
Hi guys i have 2 forms one called sender and the other called recipient, the related field for these two Forms is called "Sender ID".
When i fill in a senders details and then go to the recipient form. The recipients fom is accessed by a On Dbl_Click event on the recipient subform which is located on the sender form. When i get to the recipient Form the first thing i have to do is specify the "Sender ID", on the recipient Form, this is in the form of a combo box.
In order to avoid accidents i would like the the recipient form to take the Sender ID off the sender Form. The sender ID being the first item on the sender Form. This would save me the trouble of having to scroll down the list of sendrs ID's to find the right one, it's a pain especially when you have over a hunderd.

If you would like a sample of the Database to see what i'm referring to just let me know.
 
Try pasting this code into the Sender Subform's Code Module:

Code:
Private Sub Form_DblClick(Cancel As Integer)
    DoCmd.OpenForm "recipient"
    Form!recipient.Filter = "[Sender ID]=""" & Me![Sender ID] & """
    Form!recipient.FilterOn = True
End Sub
 
Doesn't work, keeps saying:

Run-time '2465'
Microsft Access can't find field "recipient" referred to in my expression.
 
SORRY BYTEMYZER, Here's what i should have said at the begining:
It's when i try to create a "NEW" recipient by clicking the empty spot at the bottom of the 'recipient' subform on the 'senders' form. When the recipient form opens up,I have to specify the Sender ID first before i do anything. It is at this point that i would like the recipient form to take the sender ID from the sender form.
 
Hi!
I may have missed something, but it looks like you just need to pass the SenderID from Sender form to the other form.

1.Create a Global variable for VSenderID as string (in a Module)
2.Write a Public Function to Convert the variable to a function(in the Module)

Public Function FnSenderID()
FnSenderID = VSenderID
End Function

3.On Sender form assigned VSenderID = SenderID.Text(before opening Recipient form)

4.On Recipient form assign CombBox.Text = FnSenderID() (use some event.. )
 
Yep tht's right, will try again and let you know.
 
Guys please i still need help with this. I just need the 'recipient' form to capture the 'Sender ID' from the 'Sender' form ONLY when you wish to create a new record in the recipient form.
FOR FURTHER CLARIFICATION: an earlier sample of the database is located at but will be updated later today.
 
Hi....
In my previous post Step 4 I said use some event...

should have been clearer on this, some event would refer to not assigning the the Senderid until a GotFocus or button click event.

You mentioned that you click on the bottom of the form to start a new record.Use that event to assign the SenderID and refresh your form.

For instance, if you are clicking in the first box of a new record line at the bottom of the recipient form then use that box's GotFocus event to assign the SenderID then Refresh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top