replicate fields to a second table

  • Thread starter Thread starter ilostmypants
  • Start date Start date
I

ilostmypants

Guest
I have a command button opening a separate form from my main form page. After I enter in data in the main form, hit the command button and enter data in the second form. When I close this form I get the error message "you can't add or change a record because a related record is required in table "master table'.
In my master table I have a primary key called "ID" set to autonumber. I believe the problem is this field should be replicated to the secondary table but it's not.
How can I fix this?
 
Sorry about your pants, Paul lost his flat, so sympathy on your behalf will have to wait. :)
 
This has to be a very common problem. How can I resolve this?
 
Make sure you are saving the record in the main form before opening the second window.
 
This is what my macro looks like.

DoCmd.RunCommand acCmdSaveRecord
Forms![Mobile Plans].Requery
Me![MobilePlanID] = Forms![Billing].MobilePlanID

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm "Mobile Plans", , , "[MobilePlanID] = " & Me!MobilePlanID

"Mobile Plans" is my master table/form.
"Billing" is a separate form launched from this command button
MobilePlanID is the primary key in the master table linked to MobilePlanID in the billing table.

An interesting thing I've noticed is I keep getting the error message that it can't find the billing form - however if I open the form in the background and hit the button I get the error "field cannot be updated". So obviously the update command is wrong, but why do I have to have the billing form open in the background first?
 

Users who are viewing this thread

Back
Top Bottom