Results 1 to 3 of 3
  1. #1
    Join Date
    May 2019
    Posts
    65

    Using Two Tables and Adding Records

    I have a form which uses two tables. It's not a split form. The "primary key in one table (tblCallLog) is linked to the foreign key in the second. (tblContacts)
    I use the following code to browse to the code and add a new record to the table.

    Code:
    DoCmd.BrowseTo acBrowseToForm, "frmCallLogMain",,,,acFormEdit
    Docmd.GotoRecord,,acNewRec.
    This get's me to where I want to go, but if I save the record after changes I wind up adding a new record to the tblContacts as well as the tblCallLog.


    Here is a picture showing part of the form.

    Click image for larger version. 

Name:	Screen Shot - Call Record.jpg 
Views:	11 
Size:	82.3 KB 
ID:	41575




    The Full Name field is combo unbound control, but the row source is CFullName in tblContacts.
    The fields below up to CEmail are all controls bound to fields in the tblContacts. The remaining controls "CL" are bound to fields in the tblCallLog.

    I know seeing more of the code would be more help, however I'm just looking to see if my logic is correct at the top level when i use the two lines of code.
    Does it save to both tables?

    Thanks for any help.

    Jeff

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    You only need 1 line:

    docmd.openform "formname"....use the AddNew parameter.

  3. #3
    Join Date
    May 2019
    Posts
    65
    Hi,
    The above suggestion won't work as, i neglected to explain, that this is a navigation subform.
    But thanks anyway for responding.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 09-25-2018, 11:31 AM
  2. problems adding records to tables
    By avdh0503 in forum Access
    Replies: 1
    Last Post: 02-10-2016, 07:01 PM
  3. Replies: 3
    Last Post: 01-05-2012, 12:04 PM
  4. Replies: 5
    Last Post: 12-04-2011, 10:52 PM
  5. Replies: 2
    Last Post: 04-04-2010, 06:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums