By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,188 Members | 832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,188 IT Pros & Developers. It's quick & easy.

code for saving record

P: 57
I have 2 forms called Sales and SalesMeeting. Sales has all info about sales and it has primary ID called SalesID. SalesMeeting just an additional form that hold all the meeting for the particular sales. When Sales form open and I click the SalesMeeting button, Salesmeeting form open with SalesID connects to SalesIDtextbox in Sales form. On the controlsource for SalesIDtxtbox in SalesMeeting, I used =[Forms]![sales]![SalesID], I have a save button, that save all records in SalesMeeting to a MeetingTable using DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
This command didn't save the SalesID txtbox since I didn't say to also save the SalesID to the table. My question is could you please tell me the VBA code that can save all the records as well as save the link field to a meetingTable? Thank you
May 7 '07 #1
Share this Question
Share on Google+
5 Replies


Denburt
Expert 100+
P: 1,356
Well May now we are both confused. :)

You should make sure the record is selected before saving it also Docmd.DomenuItem is sketchy at best, the preffered method is Docmd.runmenuitem I think you will find this to be much more reliable.
Note: You may not need to select the record when you tell it to directly save the record however I do it this way just to make sure.
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.RunCommand (acCmdSelectRecord)
  2.     DoCmd.RunCommand (acCmdSaveRecord)
Hope it helps let us know.
May 7 '07 #2

P: 57
Well May now we are both confused. :)

You should make sure the record is selected before saving it also Docmd.DomenuItem is sketchy at best, the preffered method is Docmd.runmenuitem I think you will find this to be much more reliable.
Note: You may not need to select the record when you tell it to directly save the record however I do it this way just to make sure.
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.RunCommand (acCmdSelectRecord)
  2.     DoCmd.RunCommand (acCmdSaveRecord)
Hope it helps let us know.
Sorry for the confusion. What I meant is on the SalesMeeting form, I have a textbox called SalesID that coming from sales form. What I want is when I click save, it also save SalesID that link from sales form to a meeting table. how can I tell the code to save SalesID to a meeting table when I click Save? The Salesmeeting form has bunch of text boxes that tight to a meeting table directly, except the SalesID. Is it still confusing?
May 7 '07 #3

Denburt
Expert 100+
P: 1,356
O.K. do you have at least 1 meeting for every sale? It sounds like your sales Meeting form could be added to the sales form and the wizards would help you link them. this would update the sales Meeting form.

If you want them as separate forms this can be done but you will need to open the salesmeeting form and carry the SalesID over to it. This can be accomplished by using the openargs of a form.

Does this help?
May 7 '07 #4

P: 57
O.K. do you have at least 1 meeting for every sale? It sounds like your sales Meeting form could be added to the sales form and the wizards would help you link them. this would update the sales Meeting form.

If you want them as separate forms this can be done but you will need to open the salesmeeting form and carry the SalesID over to it. This can be accomplished by using the openargs of a form.

Does this help?
Sorry, I'm really new with Access. If I want them as a separate form, how would I do that? Would you mind giving me the sample of the code? I just want to save the SalesID textbox along with the other textboxes to a meeting table. Thank you so much for all your help
May 7 '07 #5

Denburt
Expert 100+
P: 1,356
Sorry, I'm really new with Access. If I want them as a separate form, how would I do that? Would you mind giving me the sample of the code? I just want to save the SalesID textbox along with the other textboxes to a meeting table. Thank you so much for all your help
Simply use the OpenArgs Property as such:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click()
  2. Docmd.OpenForm "YourForm",,,,,,me!SalesID
  3. End Sub
  4.  
In the second form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. If Len(Me.OpenArgs) > 0 Then Me!Classid = Me.OpenArgs
  3. End Sub
  4.  
  5.  
May 8 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.