Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2008
    Posts
    54

    Unanswered: System date stumped

    I am getting stumped with System date. I have seen many variant examples but still could not figure why I am still getting my form “frmPassword” opened instead of frmSwitchboard. What I wanted to do is to open the frmSwitchboard if the system date is less than 31/03/2011. The other thing is that whenever I type 31/03/2011 it changes to 31/3/2011 but I think it should not affect the condition. Can someone please help?

    Private Sub Form_Load()
    If Date < "#" & 31 / 3 / 2011 & "#" Then
    DoCmd.OpenForm "frmSwitchboard"
    Exit Sub
    Else
    If Me.Ntimes > 2 Then
    DoCmd.OpenForm "frmMessage"
    Exit Sub
    ElseIf Me.PFlag = "+" And Me.Ntimes < 3 Then
    DoCmd.OpenForm "frmswitchboard"
    Else
    DoCmd.OpenForm "frmPassword"
    DoCmd.Close acForm, "frmStart"
    End If

    End If

    End Sub

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try

    If Date < #3/31/2011# Then

    You don't want the quotes with a hard-coded date, and within VBA Access likes dates in US format.
    Paul

  3. #3
    Join Date
    Jan 2008
    Posts
    54
    Thanks Paul it worked! I had tried all sorts of quotes including the US format before yet I could not figure out, but didn't know it is simple as removing the quotes.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problemo! You would need to do that type of thing if you were getting the date from a form or something, but not when you're hard-coding it like that.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •