If date statement (1 Viewer)

BobNTN

Registered User.
Local time
Yesterday, 23:40
Joined
Jan 23, 2008
Messages
308
Would someone tell me why the top part of this code doesn't do anything ?
It executes the code after the else
I have tried variations of the If Date syntax but it seems to ignore it

Code:
Private Sub Form_Open(Cancel As Integer)
   
  If Date = 2242011 Then
    MsgBox "It is Feb 24, 2011"
         
    DoCmd.OpenForm "FrmCustInfo", acNormal
         
    Else
    
' Minimize the database  window and initialize the form.
   
      ' Move to the switchboard page that is marked as the  default.
    Me.Filter = "[ItemNumber] = 0 AND [Argument] =  'Default' "
    Me.FilterOn =  True
           
    
    End If
     
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:40
Joined
Aug 30, 2003
Messages
36,137
Try

If Date = #2/24/2011# Then
 

BobNTN

Registered User.
Local time
Yesterday, 23:40
Joined
Jan 23, 2008
Messages
308
Thanks Paul.

I looked everywhere but never found the "#" syntax.

Thanks again.

BTW, can a timer be set on the message box ?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:40
Joined
Aug 30, 2003
Messages
36,137
Not to my knowledge. You could open another form in dialog mode. In that form's timer event, have it close itself after your desired interval. At that point code in the original form will continue.
 

MarkK

bit cruncher
Local time
Yesterday, 20:40
Joined
Mar 17, 2004
Messages
8,190
You can set a timer on a message box like this ...
Code:
Sub TestMsgBoxTimer()
   Debug.Print TimedPopup("Greetings!!!", 2, "Hello World", vbYesNo + vbInformation)
End Sub

Public Function TimedPopup(message As String, secondstowait As Long, title As String, options As Long)
[COLOR="Green"]'  Executes the Popup() method of a WshShell object
   '* Early Bound
   'with reference to Windows Script Host Object Model
[/COLOR]   Dim wsh As New IWshRuntimeLibrary.WshShell
[COLOR="Green"]   '* Late Bound[/COLOR]
[COLOR="Green"]   'Dim wsh As Object
   'Set wsh = CreateObject("WScript.Shell")[/COLOR]
   TimedPopup = wsh.Popup(message, secondstowait, title, options)
End Function
It returns -1 if it times out.
Cheers,
Mark
 

Users who are viewing this thread

Top Bottom