SteveL13
asked on
How force record to be saved before making an entry in a subform
I have a main form that opens with data entered in the fields from another form that is still open. So there really is nothing to enter in the main form. But I don't want the user to be able to enter anything in the sub-form until the main form record has been saved. This is because the ID of the main form record hasn't been established yet and the subform will be looking for that number.
How can I force the save of the main form record even is the user hasn't entered anything?
I did try DoCmd.RunCommand acCmdSaveRecord but it doesn't save it.
How can I force the save of the main form record even is the user hasn't entered anything?
I did try DoCmd.RunCommand acCmdSaveRecord but it doesn't save it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Simple enough. I'm using this.
I guess I'm confused about what the question was. I posted essentially the same code as Anders except I used the Dirty event of the subform so you wouldn't get the error by simply tabbing into the control. I don't believe that errors should be raised by tabbing into a control. In addition, I told you how to get the main record to save which seemed to be what your question was all about and even suggested hiding the subform until after the main form record was saved.
ASKER
Pat,
You are correct. I'm requesting attention so I can split the accepted solution.
You are correct. I'm requesting attention so I can split the accepted solution.
ASKER
Solution split. Thank you to both of you.
ASKER
Open in new window
But I can't compile. Gets stuck on ForeignKey.