Solved: Access 97 Question

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

golfer2

Thread Starter
Joined
Aug 6, 2003
Messages
76
I need to create an Access 97 application for an annual charity golf tournament. This will involve corporate sponsorships, prize and food donors, players and fees, volunteers, etc. I know it will require several tables, forms, queries and reports and I could just leave the job at that but I would like to create an application so computer illiterates can take over.

To work up to this I created an application of a directory of family and friends as a learning experience. I put a shortcut on the desk top that opens Access 97 and takes me directly to the main form on which I have buttons to add/delete entries, view or print the directory, and even print out labels. I even included a STOP button to exit the application. I was very proud of this since I haven't used Access in a while and have never written an application.

The question is this --- the STOP button shuts down the application but leaves Access open so how do I accomplish both functions with one STOP button? When I created the STOP button the following dialog gave me the option to shut down only the application. I've been retired from my previous programming job for 15 years but I think I could still handle a little bit of VB if needed. Thanks a lot for any response as it will save me a lot of time digging through manuals.
 
Joined
Jul 1, 2005
Messages
8,546
I'd no idea how to do this, so I just followed the Help.

Start with the form in Design View. You need the Toolbox open (via the View menu if necessary). Click on Command Button in the Toolbox, then click & drag a button on the form. In the Command Button wizard, choose "Application" for Category, highlight "Quit Application" for Action, click Next. The next step (of the wizard -- to define the button style) is entirely straightforward. :)

HTH,
Andy
 
Joined
Jul 1, 2005
Messages
8,546
In case the KB article's not applicable, I cribbed some code ...

Create a command button on the form. Rightclick the button, choose "Properties". On the Event tab, click in "On Click", choose "Event Procedure" from the dropdown, then click the ellipsis (?sp?) button. In the code window, use something like:

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

DoCmd.Quit

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub


NB: the steps may not be exactly the same in 97. However, mine's demanding a reinstall at the moment. :(
 

OBP

Joined
Mar 8, 2005
Messages
19,896
Don't forget to put a message box in to ask the User "are they sure they want to quit Access" like this
Dim response
response = MsgBox("Are You Sure You Want to Quit Access", vbYesNo + vbExclamation + vbDefaultButton2)
If response = vbNo Then Exit Sub ' User chose No.
'User Chose Yes
DoCmd.Quit
 

golfer2

Thread Starter
Joined
Aug 6, 2003
Messages
76
Gentlemen, thank you for your replies.

First to bomb #21 -- your first reply is exactly what I did to create the STOP button. The procedure is valid in Access 97. This quits the application but not Access itself. Your third response looks good and I think it will work. I won't have time to try it out until after the New Years holiday ( I will explain below). However, another thought occurred to me -- would it not be simpler if I created an Autoexec macro for the application? What are your thoughts and what should the macro look like?

Second to OBP -- great suggestion and I don't know why I didn't think of it. As a programming team leader I was fanatical about 1) lots of comments so someone else could understand the code and 2) your kind of suggestion to protect the user.

Now for my explanation. When you are retired for 15 years you have no time for yourself. I don't know where the days go. I can't count the computers I support pro bono for friends, family, church, hospital, etc. It does get exhausting but it is fun.

Gentlemen, Happy New Year to you both.

Carl
 

OBP

Joined
Mar 8, 2005
Messages
19,896
The autoexec macro should open the Main Menu or Form, it can't be used to quit the application although an ordinary macro could. See attached database.
 

Attachments

golfer2

Thread Starter
Joined
Aug 6, 2003
Messages
76
Gentlemen, again thank you. Following bomb #21's suggestion I added a DoCmd.Quit after the DoCmd.Close in the Event Proceedure and this worked fine. Then I copied and pasted the message suggested by OBP between the .Close and .Quit statements and this too worked fine. Thank you.

OBP, I downloaded your attached data base and after unzipping it I tried to open the Autoexecmacro.mdb but keep getting an "unrecognized format" error message. I used the Database Utilities to repair or convert the .mdb to no avail. It's probably because I am using Access 97 and Microsoft provides upward conversion but not downward. I have run into this in the past.
 
Joined
Aug 5, 2005
Messages
3,086
I'm sure this is resolved (and can be marked Solved using the Thread Tools at the top of this page) but I just wanted to add that macros are not generally preferred in Access. The AutoExec macro (like the example OBP attached) is just about the only one that has any use. I attached an ACC97 version of the file.

chris.
 

Attachments

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top