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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fail to perform action on Report_Close

Status
Not open for further replies.

TTThio

Programmer
May 3, 2001
185
US
When user tried to close the form (built-in button), I prompt the user with message box whether they'd like to save or not.

My code:
If response = vbyes then
save action
Else
docmd.close
End if

If instead of the save action I just display MsgBox, it worked.
Yet, to perform the save action or close, I get an error message:
"The action cannot be carried out when processing report/form event"

Can someone help me with this?

Thanks,
Tin Tin

 
Hi, Tin Tin, again!

Write for saving of record:
docmd.RunCommand acCmdSaveRecord

Aivars
 
That's what I wrote when I meant 'save action'. Sorry for the confusion.
It just returned the above error message.

Tin Tin
 
What do you mean with Report_Close on thread title? I only a second ago espied it. What do you want to save by event Report_Close?

If do you want to save report then maybe use attributes of docmd.close saving attributes!

Aivars
 
I'm so sorry, I don't know what I'm thinking, must be really stuck....he...

This is actually what I want to do:

Preview_Click - Open Report
Report_Close - Prompt msgbox vbYesNo
If Response = vbYes - Close Report,OutPutTo action
Else (Response = vbNo) - close Report

When the code steps into docmd.close, I get
"The action cannot be carried out when processing report/form event"

Yet, if in the "If" statement I change the code like:
If Response = vbYes - display msgbox "Report is saved"

msgbox is displayed, no error message.

Thanks ahead Aivars,
Tin Tin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top