Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting an error,3058, when form is being populated

Status
Not open for further replies.

DBritter

Technical User
Jun 28, 2000
37
US
Index or primary key can't contain a Null value. (Error 3058)
This is the message that I get when one of the forms that I have opens. The code that is associated with the command button that opens the form is as follows:

Forms!frmLookup.Visible = False
DoCmd.Close , "frmLookup", acSaveYes
DoCmd.OpenForm "frmlead", acNormal, "", "", acFormAdd, acDialog

I want the form to open in a data entry mode. This form has 2 subforms that are connected to it, and that may be causing this problem. The error occurs when the first field loses its focus after entering a company name.This error pops up twice.
Thank you for your help.
 
Hi!

No! No! No!
Error occur on close form (not on open form) action:
DoCmd.Close , "frmLookup", acSaveYes.
Any control(s) what Control Source is field with primary key isn't update (=null) before you try to save record or form have NewRecord=true.

Aivars


 
I don't quite understand how to go about this.

Could you provide some syntax for this, or point me in the right direction to find out how to write this.

thanks
 
Hi again!

You can use OnError event procedure e.g.:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3058 Then
'Primary key with null value
'Ignore the error
'and continue without displaying
'the default Microsoft Access error message.

Response = acDataErrContinue

'You can supply a custom error message
'in place of the default error message

MsgBox &quot;Enter the all necessary data or press <Esc> for cancel update action!&quot;
End If
End Sub


Aivars
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top