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

Problem Closing a Form

Status
Not open for further replies.

cpsqlrwn

IS-IT--Management
Jul 13, 2006
106
US
I am trying to close a form from the lost focus event of a control and I get the message "This action cannot be carried out when processing a form or report". This message occurs whether the form is dirty or not. The control is the last control in the tab order. Thanks for any help!
 
Do you have any other lines of code associated with this event or any other event related the said last control?
If so, can you please paste those code related to last control along with the event.
 
How are ya cpsqlrwn . . .

You may want to consider a close button using the following technique:

KISS way to force users to click a command button to exit a form regardless of menu or toolbar options

Calvin.gif
See Ya! . . . . . .
 
cpsqlrwn said:
[blue]I am trying to close a form from the lost focus event of a control and I get the message [purple]"This action cannot be carried out when processing a form or report".[/purple][/blue]
There's a subset of events that [purple]have to complete[/purple] before a form/report can be closed. The [blue]focus events[/blue] are members of this subset. Whats needed is time for the event to complete and the forms [blue]On Timer[/blue] event takes care of this problem . . . Try the following:
[ol][li]In the [blue]Declaration Section[/blue] of the forms code module, copy/paste the following line:
Code:
[blue]Private flgClose as Boolean[/blue]
[/li]
[li]In the [blue]Lost Focus[/blue] event of the control, copy/paste the following:
Code:
[blue]   flgClose = True
   Me.TimerInterval = 100[/blue]
[/li]
[li]Next in the forms [blue]On Timer[/blue] event, copy/paste the following:
Code:
[blue]   If flgClose Then DoCmd.Close[/blue]
[/li][/ol]
[blue]Thats it . . . give it a whirl and let me know . . .[/blue]


Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top