Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2009
    Posts
    6

    Unanswered: Naming report on Open using Me.Caption

    In VBA I type the following code to auto name my report with the current date when open.

    Me.Caption = "Report 1 " & Format(Date(),"mm/dd/yyyy")

    The problem is that Microsft VBA automatically as soon as i save or click away from my line takes out the "()" after Date so the line looks like this:

    Me.Caption = "Report 1 " & Format(Date,"mm/dd/yyyy")

    After it auto remove the parenthies it highlights yellow as an error.

    Why is it doing this? The code looks to be correct by what im finding on the Net.

    Any suggestions???

  2. #2
    Join Date
    Mar 2007
    Posts
    277
    Access removing the parens is normal. I tried what you have and it works just fine in ac2002.
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  3. #3
    Join Date
    Oct 2009
    Posts
    6
    For some reason mine will not work. It prompts the Debug error everytime.

  4. #4
    Join Date
    Oct 2009
    Posts
    6
    When i open the report It errors. the message reads:

    Runtime error

    Microsoft Access cant find the field 'date' referred to in your expression.

  5. #5
    Join Date
    Mar 2007
    Posts
    277
    Have you checked to see if you have any reference errors?
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Change it from Date() to Now() ?

    Odd behavior. Your references might be messed up tbh. That's the only thing that would explain Access not knowing what Date is.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Mar 2007
    Posts
    277
    How to check for reference errors: Access Reference Problems
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  8. #8
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    You need to get to the code editor and then select Tools/References. You will probably see the word Missing next to one of the checked references.

    To get to the editor, either open a module in design view or design a form and View/Code.

Posting Permissions

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