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