Link to home
Start Free TrialLog in
Avatar of GTC-KTX
GTC-KTXFlag for United States of America

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of GTC-KTX

ASKER

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.
Avatar of GTC-KTX

ASKER

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?