Results 1 to 8 of 8

Thread: Unable to assign a formated date to a label.caption

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Adelaide Australia
    Posts
    6

    Unable to assign a formated date to a label.caption

    The following code which I have used many times will not work on my new database.

    Today.Caption = Format(Now(), "d/m/yyyy")

    It gives the message

    "run time error 13 Type mismatch"

    The code works in other databases on this pc. Library files are the same and in the same order. I don't understand why it won't work.

    I would very much appreciate some help.
    David

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Is that the line that is highlighted after the error message has appeared? I used your code and it worked fine...

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Adelaide Australia
    Posts
    6
    Yes , thanks for your interest in my problem.
    I have commented out the line of code "Today.Caption = Format(Now(), "d/m/yyyy")". No more error message and I can get on with the project. But I will have to conquer it soon. It works in other databases on my PC. The problem persists if I transport the database to work (another PC).

    I appreciate that its a bit hard to work out someone elses problem without the full code. I am happy to send the DB to anyone that is interested.
    David

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Upload your project and i'll try and have a look for you.

  5. #5
    Addicted Member
    Join Date
    Aug 2003
    Location
    houston
    Posts
    185
    IS THAT LINE PASTED FROM YOUR CODE MIGHT THERE BE A SYNTAX ERROR? BECAUSE FORMAT GIVES THAT ERROR IF YOU DONT HAVE THE "d/m/yyyy"
    CORRECT

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Adelaide Australia
    Posts
    6
    Unfortunately I don't know where to upload it to, and I don't seem to be able to email it through this forum.

    I have imported a form which has exactly the the same code form another working database. Itworks in my new db. When I copy the label and the associated vba into the original form, it causes the error. It tends to suggest there is one of those hidden problems with the form, although appart from this problem it works perfectly.
    David

  7. #7
    Lively Member
    Join Date
    Jun 2003
    Posts
    114
    This may sound like a dumb question but, WHAT is the version of your new database? Can I assume this is Access you're talking about? In your format make sure that you don't have to escape the backslashes ... It may be absorbing some of your format as escape sequences and that could be blowing it for you ...

  8. #8

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Adelaide Australia
    Posts
    6
    Problem Solved. Would you believe I had a field in the underlying table named "Format". Seems perfectly logical to me. I blame Bill.

    Thanks for your help everyone. I hope you remeber reserved words in the tables when an Access form does not work for you.
    David

Posting Permissions

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



Click Here to Expand Forum to Full Width