Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Closing a form during Lost_Focus event

Author  Topic 

kobi
Starting Member

2 Posts

Posted - 2003-10-19 : 15:15:20
What is the correct way of closing a form during Lost_Focus (or any other) event?

DoCmd.Close acForm, Me.Name, acSaveYes

doesn't seem to be working, with error message saying that this action can't be carried out while processing a form or report event.

What is the best way to close a form automatically after the user has entered all the necessary data?

Thanks.

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2003-10-19 : 18:33:21
The best way? Get the user to press a save or close button and don't do it automatically.

Presumably, if they are "losing" focus on the last data control, then they are clicking somewhere else or pressing <tab>, and so they may aswell press a close or save key. Even if it's code actually does nothing, this guarantees that they have actually moved focus away from the last data control.

Maybe you have a good reason for wanting "automatic" form close?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

kobi
Starting Member

2 Posts

Posted - 2003-10-20 : 13:41:52
The thing is that my program accepts input from a barcode scanner. The scanner is programmed in such a way that it automatically generates "Enter" after data input. I want to close the form immediatelly after data is scanned into the form so that user doesn't have to bother with additional keystrokes or mouse moves.

Maybe this is a silly question, I am quite new to MS Access.
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-20 : 14:22:52
Try:

Private Sub TextBox1_AfterUpdate()
DoCmd.Close acForm, Me.Name, acSaveYes
End Sub
Go to Top of Page
   

- Advertisement -