Results 1 to 2 of 2
  1. #1
    user9 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2013
    Location
    US
    Posts
    43

    Add Record to Subform from Main Form - Getting Null Error on PK or duplicate PK

    I added an "Add Record" button to my main form. The Embedded Macro successfully creates a new record on the subform.
    When I press any key any field I get the following error: "You tried to assign the Null value to a variable that is not a Variant data type".
    When I click OK I can proceed, but why am I getting this error? What can I do to remove it (either with VBA or within the Embedded Macro)?

    Alternately, I have found that creating the "Add Record" button in my subform creates a new record but my PK field gets populated with an existing value (the first PK value in my table). The subform shows two records, both the existing record with that PK and the new record with just the PK filled in.

    Not sure which error is easier to resolve...

    Thank you in advance!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Want to provide db for analsyis? Follow instructions at bottom of my post. Identify the form involved.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 8
    Last Post: 03-13-2013, 08:32 AM
  2. Syntax Error For Main Form Subform Report
    By burrina in forum Reports
    Replies: 1
    Last Post: 12-27-2012, 03:03 AM
  3. Replies: 6
    Last Post: 08-22-2012, 03:24 AM
  4. Replies: 2
    Last Post: 12-07-2011, 02:51 AM
  5. Replies: 0
    Last Post: 01-06-2009, 02:17 PM

Tags for this Thread

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