Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Compile error (Access 2000)

    The following constant is wrongly made by me, and i get "Compile error" :

    Public Const CnstUpdate as Date > #01/01/2003#

    May i get some help?
    I wanted to insert the constant into the following line:

    StrCustomers = " SELECT customers.* INTO CustomersTemp FROM customers

    WHERE Customers.LastUpdated > #01/01/2003#"

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (Access 2000)

    You can't use > in the declaration of a constant. You must use = instead. Your SQL string could then become:

    strCustomers = " ... WHERE Customers.LastUpdated > #" & Format(cnstUpdate, "mm/dd/yyyy") & "#"

  3. #3
    Lounger
    Join Date
    Aug 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile error (Access 2000)

    Dear Hans,

    I receive a Syntax error with my constant

    Public Const CnstUpdate As Date = #10/1/2003#

    strCustomers = " SELECT customers.* INTO CustomersTemp FROM customers WHERE Customers.LastUpdated > #" & Format(CnstUpdate, "mm/dd/yyyy") & "#"


    Would you help me out ?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (Access 2000)

    I hope you put the line

    Public Const CnstUpdate As Date = #10/1/2003#

    at the top of a general module; you can't declare a public constant inside a function or procedure, or in the module belonging to a form. What is the exact text of the error message you get, and what exactly is highlighted?

  5. #5
    Lounger
    Join Date
    Aug 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile error (Access 2000)

    Thank you very much indeed for your kind attention.I think the help you gve to me and to everybody else in the Forum is enormous.

    I get the the following error :

    Syntax error in date in query expression Customers.lastUpdated > 10.01.2003

    I am sending to you the table,the form and 2 modules, in order to help me find out the reason for that error.

    Best regards
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Compile error (Access 2000)

    I think the problem lies in the date separator on your system. Try the following, which forces the separator to be / as a literal character, instead of using the Bulgarian one:

    strCustomers = " SELECT customers.* INTO CustomersTemp FROM customers WHERE Customers.LastUpdated > #" & Format(CnstUpdate, "mm/dd/yyyy") & "#"

    The backslashes in <big>"mm/dd/yyyy"</big> mean that the following character is meant to be used just as it is.

  7. #7
    Lounger
    Join Date
    Aug 2002
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile error (Access 2000)

    It works !!!!!!!!!!!!!!!!!!!!!!!!!
    Obviously the problems has lied in the date separator of my system.
    I have tried your suggestion and now the code is flying !!!!!!!!!

    Thank you once again

    i wish you a nice day and please accept my bets regards

    Primerov

Posting Permissions

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