Results 1 to 3 of 3
  1. #1
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56

    NotInlist Event not working properly

    Hi Guys

    Ive got a form with a combobox and the recordset is from a table

    i tried to open the form to enter the new data, but gives me an error

    The form has 3 fields, number,text,text

    The number is a primary key but not autoincrement.

    I found something on the internet, but tried to modified in mycase but nothing happens



    here is the code

    On Error GoTo HandleErr
    'If new person then ask to insert in the person table
    If MsgBox(NewData & " Add new Data?", vbYesNo + vbQuestion + vbDefaultButton2) = vbYes Then
    stDocName = "Persons"


    strdelim = """"
    CurrentDb.Execute "INSERT INTO Person (name) VALUES (" & strdelim & NewData & strdelim & ")", dbFailOnError
    NewPrID = DLookup("PersonsId", "Person", "Name = " & strdelim & NewData & strdelim & "")
    DoCmd.OpenForm stDocName, acNormal, , "PersonId = " & NewPrID
    Response = acDataErrAdded
    Else
    Forms!Transaction!TransactionLineDetails.Form!Prid .Undo 'clears combo
    Response = acDataErrContinue
    End If


    HandleErrExit:
    On Error GoTo 0
    Exit Sub


    HandleErr:
    Select Case Err.Number
    Case Else
    MsgBox "Error " & Err & " : " & Error$, vbCritical, "Προσοχή"
    Response = acDataErrContinue
    Resume HandleErrExit
    End Select

    -----------
    Says that an indexed or a primary key cannot contain null value Error 3058

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If the number field is not an autonumber, you'll need to add that field to your SQL and populate it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Ok solve it...

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

Similar Threads

  1. access program not working properly!
    By accesshelpme in forum Access
    Replies: 1
    Last Post: 05-13-2012, 03:43 PM
  2. NotInList event
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 04-13-2011, 09:10 AM
  3. NotInList event issue
    By elinde in forum Forms
    Replies: 1
    Last Post: 04-01-2011, 08:43 PM
  4. Cancelling the NotInList event
    By Remster in forum Programming
    Replies: 12
    Last Post: 11-21-2010, 10:12 AM
  5. Troubleshoot NotInList Event Procedure
    By skyrise in forum Programming
    Replies: 4
    Last Post: 02-23-2009, 06:06 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