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

problem with coding for closing database 1

Status
Not open for further replies.

kat25

Technical User
Feb 26, 2003
105
US
I was given this code back in May and it worked fine for me. I lost my database that I tested this event on and now I'm trying to rebuild the event on a new test database, but its not working for me now.

The only difference I am doing today is changing (date)=6 to
(date)=3. Assuming '3' is for Wednesday - so I can test it today.

Here is the help I received from AJN2004. I know the code works, but for some reason I can't get it to work for me today. This is a copy of the message from May.
**********************************************
Add the folowing code to the "On open" section in the properties dialog of your start form:


CODE
Private Sub Form_Open(Cancel As Integer)
If Weekday(Date) = 6 Then
MsgBox "Sorry the database is down today for maintenance." _
& "Please try again on Monday", vbOKOnly + vbInformation, "Database down"

DoCmd.Quit
End If
End Sub

if the day is 6 (Friday) a messag box appears informing the user that he/she cannot use the databse and closes the program.
*******************************************************

I open the properties box on my startup form and added the code to the "On Open" event for the form.

Does anyone having any ideas as to what I'm doing wrong?
Much thanks.
Kat
 
Try this:

Code:
If Weekday(Date) = 6 [red]or Weekday(Date) = [highlight]4[/highlight][/red] Then
    MsgBox "Sorry the database is down today for maintenance." _
        & "Please try again on Monday", vbOKOnly + vbInformation, "Database down"        
    [highlight]Application.Quit[/highlight]
End If

First of all Wednesday weekday is 4 not 3. I included the red code above for the wednesday testing. Also, I changed the Docmd.Quit to Application.Quit. Both will work but it is more descriptive for you code. Just remove the red code to take the testing code out.


[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Thank you so much.
I appreciate your prompt reply.

Have a great day.
 
Little confused here. Was my response confusing to you? The highlighted code does in fact point out that you Wednesday is 4 not 3. I am only asking because I like to make sure that my responses are clear.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
No, your note was not confusing. The code worked great for me.

Thanks again.
Kat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top