Eileen Murphy
asked on
Update or CancelUpdate without AddNew or Edit
Hi Experts. I haven't had this happen before -- not sure if I was just lucky or what... A client kept getting the above error (not consistently) when changing fields in a bound form.
After much hair pulling I got rid of it by eliminating default values in a sub form -- some fields had them hard coded in the form itself, and others were dynamic and had to be changed in code.
I know I've used them before and can't for the life of me figure out why this is happening...
Any idea? What was I doing wrong?
Thanks.
After much hair pulling I got rid of it by eliminating default values in a sub form -- some fields had them hard coded in the form itself, and others were dynamic and had to be changed in code.
I know I've used them before and can't for the life of me figure out why this is happening...
Any idea? What was I doing wrong?
Thanks.
ASKER
Here's the forms OnCurrent event:
Private Sub Form_Current()
If IsNull(Me.ORDER_DATE) Then
Else
Me.SALESYR = DatePart("yyyy", [ORDRDATE])
DoCmd.RunCommand acCmdSaveRecord <<<<< Added this -- didn't help
End If
Me.ContactKey.Requery <<< When Customer Selected, Contact
If Me.Terms = 5 Then
Me.SpecialTerms.Visible = True
Else
Me.SpecialTerms.Visible = False
End If
Forms!switchboard!OrderRec ID = Me.OrderRecID
>>>>>Commented the below out to get rid of the error <<<<<
' If IsNull(Me.PONUM) = False Then
' Me.sfrmOrderDetails!PONUM. DefaultVal ue = "'" & Me.PONUM & "'"
' End If
' If IsNull(Me.ENGINEER) = False Then
' Me.sfrmOrderDetails!ENGINE ER.Default Value = "'" & Me.ENGINEER & "'"
End If
End Sub
Private Sub Form_Current()
If IsNull(Me.ORDER_DATE) Then
Else
Me.SALESYR = DatePart("yyyy", [ORDRDATE])
DoCmd.RunCommand acCmdSaveRecord <<<<< Added this -- didn't help
End If
Me.ContactKey.Requery <<< When Customer Selected, Contact
If Me.Terms = 5 Then
Me.SpecialTerms.Visible = True
Else
Me.SpecialTerms.Visible = False
End If
Forms!switchboard!OrderRec
>>>>>Commented the below out to get rid of the error <<<<<
' If IsNull(Me.PONUM) = False Then
' Me.sfrmOrderDetails!PONUM.
' End If
' If IsNull(Me.ENGINEER) = False Then
' Me.sfrmOrderDetails!ENGINE
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Rachel - I need to requery the contact field OnCurrent because as they move through the records I need the records filtered by the Customer Field in each. I also requery it when they change the Customer.
I will put the defaults on the form as suggested -- I think I moved it here because they had a problem where the default value retained the value from the previous record on occasion, so I was trying to force it here...
I also didn't say that the error was occurring not just on new (yet unsaved) records, but on existing ones as well -- those that had sub-records already in the sub-form. Isn't that weird?
Thanks a lot for your help.
I will put the defaults on the form as suggested -- I think I moved it here because they had a problem where the default value retained the value from the previous record on occasion, so I was trying to force it here...
I also didn't say that the error was occurring not just on new (yet unsaved) records, but on existing ones as well -- those that had sub-records already in the sub-form. Isn't that weird?
Thanks a lot for your help.
You can test this by restoring all your old defaults at both levels and then switching the form to Cycle Current Record only. Then put a SAVE button on the page and see if it grumbles at you - if it does, it'll probably tell you which field it thinks it still needs.
-Rachel