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!

Perhaps I should reiterate the question...

Status
Not open for further replies.

mguidry5

Technical User
Jan 11, 2005
91
US
I'm opening a form called frm400section from a switchboard using the acFormAdd and acFormDialogue arguments. There is a subform on this form called sbf400section. They are linked with a one-to-one relationship on a field called LogID which is a primary key autonumber field on the main form.

When I add a new record to frm400section I get this error: "Index or primary key cannot contain a null value." There is a Form_Current event on the subform that enables/disables fields based on values in other fields of the subform - I believe this code is the culprit. I've attached the code. Is there a way to open this form and allow the Form_Current event to work without error?
Code:
Private Sub Form_Current()
If cboAbsorber1.Value = 1 Then
    Me.Absorber1Caustic.Enabled = True
Else
    Me.Absorber1Caustic.Value = Null
    Me.Absorber1Caustic.Enabled = False
End If
If cboAbsorber2.Value = 1 Then
    Me.Absorber2Caustic.Enabled = True
Else
    Me.Absorber2Caustic.Value = Null
    Me.Absorber2Caustic.Enabled = False
End If
End Sub
 
Maybe this will help...

Code:
Private Sub Form_Current()
    If not isnull(me.LogID) then
       'Do all your if statements in here
    else
       me.Absorber1Caustic.Enabled = False
       me.Absorber2Caustic.Enabled = False
    End If
End Sub

Q: Why are you assigning the value to null?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top