×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Can you close an Access97 form from within an event of a control?

Can you close an Access97 form from within an event of a control?

Can you close an Access97 form from within an event of a control?

(OP)
I keep getting an error when I attempt to close a form from within the LostFocus event of one of it's controls. I am beginning to think it cannot be done and would appreciate a confirmation of this.
  I can close the form from a command button on it but not within a control. I sure would like to however.
   The context is a form to enter data record for a problem database. One of the fields to complete is named lognumber and must be a unique number (it is indexed). I perform a dLookup on the table to determine if the lognumber already exists. If it does I send a message to the user stating that they are attempting to enter a duplicate number and give them a CANCEL or OK choice.
    The CANCEL sends them back to the control to rekey if that is the problem.
     The OK button opens code where I change the lognumber, write the record, delete the record, then I want to close the form. It seems that no matter how I code it, if a CLOSE is within the event procedure I get the error.
      I have tried a function in a module but still get the error, I guess because the procedure in the control event still has not completed. I have tried to goto a control OnClick event to close the form but still no luck.
    Any advice as to how to deal with this will be appreciated.
    Regards,
       Sorrells
     

RE: Can you close an Access97 form from within an event of a control?

So after they enter the last bit of data in the last textbox on the form you would like it to close. right?



DougP, MCP
 dposton@universal1.com
 
 Ask me how Bar-codes can help you be more productive.

RE: Can you close an Access97 form from within an event of a control?

(OP)
Doug,

No, it is more complex than that. Rather than go into detail, let me tell you that a solution was suggested in another forum, that I use the AfterUpdate event rather than LostFocus for the textbox. This does work however it will take some time to resolve other issues that had lead me to the LostFocus event in the first place.
   I am still of the opinion that the LostFocus event of a form control will not support the closing of the form at all.
   Thanks for your response! Sorrells   

RE: Can you close an Access97 form from within an event of a control?

I'm inclined to agree. While the LostFocus is executing, you still have pending Enter and GotFocus events for another control. The pending events may be what prevents the Close. What kind of error are you getting, BTW?

Instead of closing in LostFocus, you could try setting TimerInterval to 1 ms. In the Timer event, close the form. That might work, and would let you continue using LostFocus to resolve the "other issues".

RE: Can you close an Access97 form from within an event of a control?

(OP)
The error was 2585 (this action can't be carried out when processing a form). On a suggestion from Jimmy the Greek I moved the code to AfterUpdate but now I am curious since I know nothing about the timer event.
    I just looked at the help for timer and feel no less enlightened. We have never used this event here. I wish MS would provide more context to their help descriptions.
    Rather than take up your time, I'll leave this as is, but I will be more aware of this Timer event to see if I can take advantage of it in the future.
    Thanks,

Sorrells

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close