Cant close a form

G

Guest

Can someone please help

i get this error msg 'Runtime Error 2585, this action cant be carried out
while processing a form or report event

Here is my script

'If Quote Exceeds Quote Valid For Days Then Display MsgBox.

If Date >= (QuoteCreatedDate + Quote_Valid_For_Days + 1) And
Combo73.Value = "Quote Sent" Then
Dim Response3 As Byte
Response3 = MsgBox("Quote Has Exceeded Valid For Days. Status Will
Change To Quote Rejected ", vbInformation, "Work Order's Database")
If Response3 = vbOK Then
Frame384.Value = 2
Combo73.Value = "Quote Rejected" 'Status to Quote Rejected.
DoCmd.Close acForm, "Work Orders"
Else
End If
End If


on clicking ok on the msgbox certain events occurr on my form "work orders"
and them im trying to close the form. the code DoCmd.Close acForm, "Work
Orders"
is bringing this error msg up.

Does anyone know how i can close my form when the events have finished.

Thanks to anyonewho looks into this
 
W

Wayne Morgan

You have made changes that require saving. When you try to close the form,
the BeforeUpdate and AfterUpdate events need to run. You may have code in
those also and I'm guessing that is causing your problem. Attempt to
explicitly save the changes before closing the form so that those events
won't need to run.

Example:
Combo73.Value = "Quote Rejected" 'Status to Quote Rejected.
If Me.Dirty Then Me.Dirty = False 'this will save the changes
DoCmd.Close acForm, "Work Orders"
 
G

Guest

Thanks for info. i should of mentioned that my script is in the forms current
event. Does this change your thoughts?? there is no before or after events
associated with this form.
 
W

Wayne Morgan

You won't be able to close the form in the current event. You can hide it
though if that helps (Me.Visible = False). This will remove it from the
user's view and you can close it later if you need to. You can also close
the form in a button click event on the form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top