?
Solved

MS Access - Saving Records on various tabs of a tab control

Posted on 2009-04-06
5
Medium Priority
?
312 Views
Last Modified: 2012-05-06
I have an Access form which has a tab control with 9 tabs.
The entire form is for the input of data associated with one particular sales opportunity.
6 of the 9 tabs populate data into the main salesoppornity table (1 record per sales opportunity).  The other 3 tabs populate 3 other tables.  One is a document attachment table (DocAttachments), one is a phone conversation log table (PhoneLog), and one is a meeting log table (MeetingLOG).
I have a "save and new" command button in the form header which i did similar to the Microsoft Access Sales Pipeline example, whereby hitting this button saves the opportunity, clears the fields, and increments the ID to a new opportunity for input.
What i would like to do, is on the "phone log" tab, have buttons where i could save and increment to a new record, only those fields on that tab (relating to the phone log table).  This is obviously because you could have many phone logs records for a particular sales opportunity.  This would be the same with the Meeting log tab.  I was hoping someone could give me some direction on accomplishing this.
0
Comment
Question by:GTC-KTX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 24079158
place the button in the subform and use the codes

private sub Btn_click()
if me.dirty then me.dirty=false 'saves the current record
currentdb.execute "insert into PhoneLog(OpportunityID) values (" & me.parent.opportunityID &")"
me.requery

end sub

this assuming that the PhoneLog table is associated with the "Opportunity" table using the "OpportunityID"




0
 
LVL 4

Expert Comment

by:Rodger
ID: 24079198
Are you not using the AutoNumber for the DocAttachments, PhoneLog, and MeetingLog Tables?  Using the PhoneLog I would create a form with all the info I need then on the main form I would add a subform and link the two with the phoneLogID.  So in the phoneLog table you need a field that will hold the ID (PK) from your main table.  Now when ever a new phoneLog is entered it will update the table with the appropriate ID and what ever information is entered on the form.
Does this help?
Rodger
0
 

Author Comment

by:GTC-KTX
ID: 24079795
Capricorn1,
Placed the code you suggested in the form.  I cant test it yet to see if it works due to a problem i'm having whereby i can see all the controls, etc in my form when in design view, when i toggle to form view everything disappears except the header (this is something i posted in another thread).  Just wanted to let you know i can't test your solution yet until i get that solved in the other thread.

Rodger,
I am using the Autonumber for each of those 3 tables as well as the main opportunity field.
So there is an ID field for each phone record which auto numbers, and likewise there is an ID field for each meeting record which auto numbers.
The Primary key for the main Sales Opportunity also has an ID field that auto numbers.  This Sales Opportunity ID field is also inserted into the other 3 tables as a foreign key.
0
 

Author Comment

by:GTC-KTX
ID: 24098047
Hey Guys, I got my other issue solved so i'm back trying to solve this.
Capricorn, This is the same project that we had worked with the table associations yesterday, so yes, the phone log table is related to the Opportunity table.  The Primary Key (the opportunityID) of the opportunity table is a foreign key on the Phonelog table.  I decided that i wanted to add both record navigation and operation buttons to the phone tab, so using the command button wizard, i placed record navigation, and record operation buttons on the "Phone Log" tab.  As i suspected, even though these buttons are on just one tab, they apply to the entire form.  So if i am on opportunity record ID 5 and phone record ID 1, and hit the record navigation button to go to the next phone record, it increments both the phone record to ID2, and the opportunity record to 6.  Obviously this is incorrect.  I just want these particular buttons to control only that tab (the phonelog table).  I notice that the wizard that i used to place these controls places a macro in the "on click" event:

Condition:                  Action:           Arguments:
                                  OnError              Next,
                               GoToRecord      ,,Next,
[MacroError]<>0     MsgBox            =[MacroError].[Description],Yes, None,

Is this the entire macro?
Is there a way a can modify it to work with only the phone log tab?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question