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

DoCmd.Close problem

Status
Not open for further replies.

altoona

Programmer
Joined
Jul 31, 2001
Messages
7
Location
US
In an on exit event from a text field, I have a condition and if its true then I want to close the form.
So I issue the DoCmd.Close. However I get this error message.
Run-time error '2585'
This action can't be carried out while processing a form or report event.

Why not??
 
I'm not an expert with Access forms, though I have been getting by pretty well learning this stuff all summer long. When I've been trying to run visual basic code when exiting a text field, I found myself stuck trying to run certain commands from within certain events. In my case I wanted to check if the entry was valid, and if not set the focus back to that text field, and a few more details worked in. What I did was created a global variable as a boolean within the form's code, and in the form's onload event set the variable to false. Then on the text field's before_update event I'd check the validity of the field and if it were invalid I set the boolean variable to true. Then on the text field's lost_focus event if that boolean variable were true I could then set the focus back to the text field and set the boolean variable back to false.

Give this a try, modify it a bit to fit your situation, like check your condition in the before_update event then close the form in the lost_focus event. I can't guarantee this will work as I've never done this myself, but it's always worth a shot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top