+ Reply to Thread
Results 1 to 5 of 5

Dates changing from userform when saved

  1. #1
    Registered User
    Join Date
    07-13-2010
    Location
    Barossa SA, Australia
    MS-Off Ver
    Excel 2007
    Posts
    48

    Dates changing from userform when saved

    Hi,
    I'm having some problems with a piece of code that allows the user to save changes to data previously entered it saves over the old information. The problem occurs in only two of the date fields when they save the changes the day and month swap around even though these fields had no alterations made to them. Code below, but I'm not sure if its this or I need to make a global declaraltion that data in these date columns is to be saved in xyz format.

    Please Login or Register  to view this content.
    An example below the top line is correct the bottom is not and its allows the first date field and the last date field that have the issue.

    11/04/2011 15/05/2011 25/04/2011 08/05/2011
    4/11/2011 15/05/2011 25/04/2011 5/08/2011

    I have set the date format for the text box in the user form with code shown below.

    Please Login or Register  to view this content.
    Hope this make sense.
    Cheers BJ5352
    Last edited by BJ5352; 04-08-2011 at 03:21 AM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dates changing from userform when saved

    Use CDate when assigning the value to the cell:
    Please Login or Register  to view this content.
    is the basic syntax.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    07-13-2010
    Location
    Barossa SA, Australia
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Dates changing from userform when saved

    Thanks, this works when all date fields have dates but if there is no date in one of them it creates an error 13 Mismatch.

    How do I get around this?

    Cheers BJ5352

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Dates changing from userform when saved

    Test for a date first:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-13-2010
    Location
    Barossa SA, Australia
    MS-Off Ver
    Excel 2007
    Posts
    48

    Re: Dates changing from userform when saved

    Thanks that did the trick
    Cheers BJ5352

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1