Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 VBA Question - Please

Author  Topic 

paul27uk
Starting Member

9 Posts

Posted - 2007-10-31 : 08:49:10
Hi, I have a form which records data relating to applications. In addition, I have another form that stores notes against the said applicant.

The issue that I am having is that I have a button to go and open the notes form and link, where possible the notes so only the applicants notes are displayed. It falls down where I create a new applicant and before the submitted to the table it errors due to the join integrity (must have a record in applicant). Is there any VBA that simply commits the record before showing the note? So that the record is already in the database before a note is created?

Thanks

Bit Wrangler
Starting Member

9 Posts

Posted - 2007-11-02 : 08:22:37
I think what you're looking for is: DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

You might also consider embedding the notes form on the same form as the applicant form as a subform. Access should force the parent record to commit and provide the foreign key value when focus is set to the subform.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-11-02 : 10:11:35
I recommend to use this, it is shorter and if any menu items are disabled you may get errors with the previous suggestion:

DoCmd.RunCommand acCmdSaveRecord



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

Bit Wrangler
Starting Member

9 Posts

Posted - 2007-11-02 : 11:04:32
Jeff's right. I forget about DoCmd.RunCommand. I learned the other way first. I think RunCommand was added in a later version than what I started in. Good catch, Jeff.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-11-02 : 14:49:27
Hi Bit -- I believe that is correct, originally you had to use the MenuItem method.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -