DateValue() nor working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Georges Heinesch

    DateValue() nor working

    Hi.

    Why is this DAO line producing error 3077 (Syntax error in number in
    expression)?

    rst.FindFirst "ValidFrom = " & DateValue(varDa te)

    rst is a defined recordset
    varDate is a valid date.
    ValidFrom is a valid field of the underlying table.

    This line works!
    rst.FindFirst "ValidFrom = #01,01,2000#"

    TIA

    --
    Georges

  • John Mishefske

    #2
    Re: DateValue() nor working

    Georges Heinesch wrote:[color=blue]
    > Hi.
    >
    > Why is this DAO line producing error 3077 (Syntax error in number in
    > expression)?
    >
    > rst.FindFirst "ValidFrom = " & DateValue(varDa te)
    >
    > rst is a defined recordset
    > varDate is a valid date.
    > ValidFrom is a valid field of the underlying table.
    >
    > This line works!
    > rst.FindFirst "ValidFrom = #01,01,2000#"[/color]

    You need to delimit the date returned by DateValue(). It returns
    a Variant (of subtype Date) so try this:

    rst.FindFirst "ValidFrom = #" & DateValue(varDa te) & "#"

    But if varDate is a valid Date field then all you need to do is:

    rst.FindFirst "ValidFrom = #" & varDate & "#"

    --
    '-------------------------------
    ' John Mishefske
    '-------------------------------

    Comment

    • Georges Heinesch

      #3
      Re: DateValue() nor working

      John Mishefske wrote:
      [color=blue]
      > You need to delimit the date returned by DateValue(). It returns
      > a Variant (of subtype Date) so try this:
      >
      > rst.FindFirst "ValidFrom = #" & DateValue(varDa te) & "#"
      >
      > But if varDate is a valid Date field then all you need to do is:
      >
      > rst.FindFirst "ValidFrom = #" & varDate & "#"[/color]

      Thanks for your reply.
      Both of your suggestions were tested already before.
      Both produced error 3077.

      varDate is valid.
      print.debug varDate says "01.01.2000 "

      I have no clue what goes wrong here!

      --
      Georges

      Comment

      • Georges Heinesch

        #4
        Re: DateValue() nor working

        Georges Heinesch wrote:
        [color=blue]
        > Thanks for your reply.
        > Both of your suggestions were tested already before.
        > Both produced error 3077.
        >
        > varDate is valid.
        > print.debug varDate says "01.01.2000 "
        >
        > I have no clue what goes wrong here![/color]

        I found the error! In fact, the date was not formatted according to the
        american system (but due to the locale settings, to the european
        system). The code below did the job:

        "ValidFrom < #" & Format(varDate, "mm\/dd\/yyyy") & "#"

        Thanks.

        --
        Georges

        Comment

        Working...