Access 97, runtime error 5

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • canblue
    New Member
    • Dec 2006
    • 7

    #1

    Access 97, runtime error 5

    I am using Access 97 on a Win XP platform. The following code is attached to the On Entry event. I have tried this in Access 2003 and it works but not in 97

    Private Sub s_addcomments_E nter()
    Dim varAA As String
    varAA = Format(Now(), "dd mmm yyyy at hh:mm:ss AMPM")
    Debug.Print varAA
    End Sub

    If I comment out the Format line there is no error. I do not understand this.

    Thanks.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    You could try replacing the line with :
    Code:
    varAA = Format(Now(), "dd mmm yyyy at hh:nn:ss AMPM")
    BTW It may also be worth renaming your String field (varAA) as strAA. Misleading prefixes are likely to cause you problems ;)

    Comment

    • canblue
      New Member
      • Dec 2006
      • 7

      #3
      Originally posted by NeoPa
      You could try replacing the line with :
      Code:
      varAA = Format(Now(), "dd mmm yyyy at hh:nn:ss AMPM")
      BTW It may also be worth renaming your String field (varAA) as strAA. Misleading prefixes are likely to cause you problems ;)
      Thanks for pointing out the str. Coming from the main frame, var notation was for variable(my usage). I changed your notation for time format from hh:nn:ss to hh:mm:ss. I still get the runtime error -- "Invalid procedure call or argument". I cannot see the error.
      Checked some other examples but the light still has not gone on.

      Appreciate your comments and assistance.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Hard to say as I don't have Access97 here atm.
        Try :
        Code:
        Format(Now(), "dd mmm yyyy \a\t hh:nn:ss AMPM")
        just on the off-chance.
        BTW var... generally refers to Variant data-type in VB/VBA rather than variable.

        Comment

        Working...