Link to home
Start Free TrialLog in
Avatar of Eileen Murphy
Eileen MurphyFlag for United States of America

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.
Avatar of RemRemRem
RemRemRem
Flag of United States of America image

It sort of looks like the form's sort order may be out of whack so that a certain field they're filling and subsequently probably hitting ENTER or TAB afterwards is trying to move to the next record. However, required fields may not be entirely filled in, or fields that cause need for others to be filled in are while the related fields aren't...thus, it tries to move to a new record without having a completed old record. I suspect the code layer had more impact on this than the table-side layer.

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
Avatar of Eileen Murphy

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!OrderRecID = Me.OrderRecID
   
>>>>>Commented the below out to get rid of the error <<<<<

   ' If IsNull(Me.PONUM) = False Then
   '     Me.sfrmOrderDetails!PONUM.DefaultValue = "'" & Me.PONUM & "'"
   ' End If
   ' If IsNull(Me.ENGINEER) = False Then
   '     Me.sfrmOrderDetails!ENGINEER.DefaultValue = "'" & Me.ENGINEER & "'"
    End If
   
End Sub
ASKER CERTIFIED SOLUTION
Avatar of RemRemRem
RemRemRem
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.