Form Will Not Close

G

Guest

i have a form which when opens a pop up msgbox occurrs giving the user some
infomation. When the user selects OK (this is the only cmd) VBA udates
certain text boxes within the form.

I then want the form to close straight away but my code isnt working.

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

form_Current()

'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
 
A

Allen Browne

StuJol, this really needs another approach. Any code that changes values in
Form_Current is going to lead to problems at some point.

It appears that you *always* want to treat a quote as rejected when it times
out. In that case, storing the status is non-normalized, i.e. it breaks the
basic rule of never storing a dependent value. You could avoid the problem
by creating a query with a calculated field, and typing this expression into
a fresh column in query design:
IsRejected: (Date() >= (QuoteCreatedDate + Quote_Valid_For_Days + 1))

If you want to go ahead with your existing approach anyway, you could try
saving the record in Form_Current. Just before the Close line, add:
Me.Dirty = False
I don't know if that will work, because I never changes values in
Form_Current.
 

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