Results 1 to 3 of 3
  1. #1
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94

    PK Missing on add new record

    Access 2010 front end UI and a MySQL back end.



    I am opening a form on a click event to add a new record.

    When the form opens, I can add data and the save and close the form - everything works fine.

    At the time the record is saved, the PK is created and all data is saved. Until then, there is no PK.

    I would like to create a PK when the form is opened, and know what the value of the PK is when created.

    How would I go about doing this.

    Here's the click code that I use to open the form and add a new record:

    Code:
     DoCmd.OpenForm "frm_devices", acNormal, "", "[ID]=" & Nz(ID, 0), , acDialog
        If (IsNull(ID)) Then
            TempVars.Add "CurrentMCDID", Nz(DMax("[ID]", Form.RecordSource), 0)
        End If
        End
        DoCmd.SearchForRecord acForm, "frm_devices", acFirst, "[ID]=" & TempVars!CurrentMCDID
        TempVars.Remove "CurrentMCDID"

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441

  3. #3
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    Thank you, that did the trick for me.

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

Similar Threads

  1. What is missing in it?
    By cap.zadi in forum Forms
    Replies: 7
    Last Post: 10-05-2011, 12:47 AM
  2. Replies: 1
    Last Post: 07-13-2011, 11:30 AM
  3. Missing object .from
    By jmclemore in forum Access
    Replies: 3
    Last Post: 02-09-2011, 07:23 PM
  4. ok what am i missing here ?
    By baseborn in forum Forms
    Replies: 6
    Last Post: 12-21-2010, 01:46 PM
  5. Find Missing Number in Sequence per Record
    By escuro19 in forum Programming
    Replies: 1
    Last Post: 11-10-2009, 03:15 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