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

Insert Into error on form/subform

Status
Not open for further replies.

caburky

Technical User
Jul 11, 2007
12
US
I have 3 Tables - that each have their own data entry form. All 3 tables are related through a one to one relationship.

I have added the following code to the AfterInsert event of the parent form:

Private Sub Form_AfterInsert()
If Me.NewRecord = True Then
CurrentDb.Execute "Insert Into Table2 (ClientID) Values(" & Me.ClientID & ")", dbFailOnError
CurrentDb.Execute "Insert Into Table3 (ClientID) Values(" & Me.ClientID & ")", dbFailOnError
End If
End Sub

After completing the parent form I encounter a compile error when I put my cursor in the subform – method or member not found. If I stop the debugger and return to the subform I am able to continue to the subform displaying the correct ClientID. It seems like a a timing thing, as though my parent form is not saving to Table1 quickly enough. Do I need to add another step or is it perhaps on the wrong event?
Thank you!!
 
Figured out where I went wrong, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top