+ Reply to Thread
Results 1 to 3 of 3

CDate not working in the correct format

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-27-2010
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    115

    CDate not working in the correct format

    Hi,

    i have a workbook with 3 userforms (to insert data, search data, and add/change data).
    Everything is working but i can't resolve a problem regarding the cdata format.

    In the frmnewrecord, i have several txtboxes and cboboxes.
    The txtbox "End Date" is not supposed to be filled (only after using the add/change data userform). My problem is that if i define the txt box as Cdate, i can't leave it blank. Otherwise the date is inserted in the format "mm-dd-yyy" and not "dd-mm-yyyy" as i need.

    I've tryed changing the code in the search data, and add/change data userforms but it just doesn´t work.

    Can anyone help me, so i can finalize this workbook?

    I send the workbook as attachment

    thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: CDate not working in the correct format

    Do you mean using CDate to enter to the sheet?
    maybe
     If Not IsEmpty(Me.txtdataregularização) Then
            ActiveCell.Offset(0, 9) = CDate(txtdataregularização)
            End If
    I wouldn't use the loop to find the next empty row either, this could prove slow in larger databases. Take a look at the database form
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    04-27-2010
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: CDate not working in the correct format

    Thanks for the help, but it's not working.

    I've tryed inserting the code you suggested but it doesn't work. Please, try running the userform to see the error.

    I also think i wasn't clear in the first post. what i need is:
    1) Insert data in the "New Record" userform, leaving the txtdataregularização blank.
    2) some days later, i need to insert (using the frmedit) the correct date in the txtdataregularização.

    My problem: I want to insert the date in the format "dd-mm-yyyy", but if i do that, in the sheet "Base Dados" the format will be "mm-dd-yyyy"

    Sheet in attachment.
    thanks once again
    Attached Files Attached Files

+ 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