Link to home
Start Free TrialLog in
Avatar of DavidDF1913
DavidDF1913Flag for United States of America

asked on

Add a table record table linked to a sub form to correct table

I have 2 basic tables: clientTbl and MatterTbl. They are joined by the client no. and matter no. fields in both in the tables. The matterTbl contains jobs related to particular clients. A client might have two matters or a hundred.

ClientTbl fields: cCno, cMno (both numeric), client (char). MatterTbl: mCno, mMno, matterName (char).
My primary form has the client table and the sub form contains the matter table.  

I want to have command buttons that will say: add Client, add Matter, delete Client, delete matter. Adding a new client will just create a blank client record but adding a matterTbl record must insert the client no (cCno) displayed in the primary form and the matter no (mMno) can be blank (usually last matter number for the client plus one).  I also want to specify which tables the records are added to. Here is my add client code:

Private Sub ComSaveClient_Click()
' add matter from client form
On Error GoTo Err_ComSaveClient_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_ComSaveClient_click:
    Exit Sub
Err_Command34_Click:
    MsgBox Err.Description
    Resume Exit_ComSaveClient_click
End Sub

Thank you for any help you can offer.
David
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation 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
SOLUTION
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
Avatar of DavidDF1913

ASKER

Thank you for your help.  You are both right. The matter no.  is not needed in client table.  However, neither client_no. or matter_no. are always entered in numerical order since this is an old database with missing clients and matters.
I am going to use the auto-number fields for client and matters tables, however, since most additions will be in order even while the database is being updated.
David