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

How and when to connect to Microsoft Access

Status
Not open for further replies.

eelsar

Technical User
May 20, 2002
36
US
I am writing a program that is to be connected to a Microsoft Access Database. The user enters information on the form and that info should go into the database. When should I update all the information into the datase, when the control box loses focus, or when then user finishes with the form (but then what happens if the user switches to another form in middle)? How would I type such a statement?

Thank you!
 
As a general data entry form would use some sort of apply/add and cancel button to detemine what the user is trying to do. This also allows you to validate that all the required infomation is present to add the data to the DB. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
And, you might want to use a Private Form level boolean variable in the form, (bEditInProgress, or bSaveNeeded, or whatever), which is set to True as soon as the user makes a change (in any edit Control's Change event). If the user then tries to close the form (or move to another record), you can check the value in the Form_QueryUnload event (or the ADO WillMove event, or when the control is clicked that moves to another record). If the value is True, the pop up a MsgBox, asking the user if they want to save or not. If they want to save, then execute the save method, or set the Cancel variable to True to cancel unloading the form.
Once saved, or if they do not want to save, set the Boolean back to False.

If the user closes the application, then each Form's Form_QueryUnload event will kick into action, and if there is code there to check if the Edit boolean is set to true, the application termination will not take place, if everything is done correctly. *******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top