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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter a new record in a filtered pop up form.

Status
Not open for further replies.

Steven811

Technical User
Apr 15, 2004
76
GB
Hi

I need the foreign key value to update when I enter a new record.

I've tried setting the default value to the primary key value of the parent form and that didn't work. I've also had the suggestion of setting the BeforeInsert event, I used the following code here and this didn't work either.

[Me!ParentForm.PrimaryKey=Forms!PopUpForm!ForeignKey]

Receive the following message:

The expression Before Insert you entered as the event prperty setting produced the following error: The object doesn't contain the automation object 'Me.'

Both of the forms are sourced through queries.

Any help would be appreciated.

Steven811
 
Did you try
Code:
Forms!PopUpForm.TxtBoxName.text = Forms!MainForm.TxtBoxName.Value
Try this thread702-986458 also

Zameer Abdulla
Visit Me
 
Hi

I receive the error message that it can't find the main form (although in my case it is a subform)

Steven811

 
You have to change the [purple]Purple bold[/purple] to actual name of the forms and black bold to actula textbox name
Code:
Forms![purple][b]PopUpForm[/b][/purple].[b]TxtBoxName[/b].text = Forms![purple][b]MainForm[/b][/purple].[b]TxtBoxName[/b].Value

Zameer Abdulla
Visit Me
 
Sorry if I haven't explained my self. That is what Ive done, I've checked the references too.

My actual code is:

Private Sub Form_BeforeInsert(Cancel As Integer)
Forms!forProject2.ContactKey.Text = Forms!subformContacts2.ContactKey.Value
End Sub

My error msg says that Access can't find subformContacts2
 
Forms!forProject2.ContactKey.Text = Forms![purple]YourMainFormName.Form.[/purple]subformContacts2.ContactKey.Value
Because the subform is in the main form you have to refer the main form then the sub form.
Also see How to Refer to Form and Subform properties and controls
it is time to move see you tomorrow
Regards


Zameer Abdulla
Visit Me
 
Forms!forProject2!ContactKey.Value = Forms!YourMainFormName!subformContacts2.Form!ContactKey.Value

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top