+ Reply to Thread
Results 1 to 3 of 3

Excel 2010 - VBA Userform - Displaying Textbox Date as 'Day' in label

  1. #1
    Registered User
    Join Date
    09-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 365
    Posts
    51

    Excel 2010 - VBA Userform - Displaying Textbox Date as 'Day' in label

    Hi there
    Thank you for taking the time to check this out

    I have a 2 page Multi-page form. On page 1, I have a txt_Inc_DATE textbox and a lbl_Inc_Day label.

    The objective is, when a user enters the date of the incident in the txt_Inc_DATE textbox (in the format: dd/mm/yyyy), I would like the date to be displayed in the lbl_Inc_Day label as "ddd" (eg. Fri, Mon, Thu .... etc)

    If the txt_Inc_DATE textbox is empty, I would like the lbl_Inc_Day label to be blank.

    I'd also like the lbl_Inc_Day to refresh if the user edits the txt_Inc_DATE.

    Would the code be under the form_initialize procedure or under the lbl_Inc_Day label sub procedure?

    I have tried the following ... but no matter how I 'tweek' it ... I get errors.

    Here is the code that I have been playing with:

    Please Login or Register  to view this content.
    I appreciate any assistance that you may be able to provide me

    TheShyButterfly

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,609

    Re: Excel 2010 - VBA Userform - Displaying Textbox Date as 'Day' in label

    1. The FORMAT FUNCTION has two parts, the thing to be formatted and the description/specification: Format(data,"format spec").
    Your code: Format("dd/mm/yyyy"), is missing the first parameter. You aren't telling it what to format.

    2. The textbox change event only triggers when you have entered your date so I don't know what the line Me.txt_Inc_DATE.Text = Format("dd/mm/yyyy") is supposed to do.

    You did not post a sample workbook so suggestion:
    a) check if the contents of the textbox is a date and modify the label if true:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 03-28-2015 at 09:33 PM.

  3. #3
    Registered User
    Join Date
    09-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 365
    Posts
    51

    Re: Excel 2010 - VBA Userform - Displaying Textbox Date as 'Day' in label

    Hi ProntonLeah,

    My sincere apologies for the delay in response, due to 2 family crisis', I haven't had much chance to continue with my project. Now things have settled down, so I can return to it now.

    Thank you for you response. I have just used the code and it works perfectly and I have a pop up message window when they enter the date in the wrong format, which works OK.

    So to summarise what I have at the moment with the date textbox I have the following code:

    HTML Code: 
    The only problem I find is that, if the user enters the incorrect date and move from the textbox, the DAY label enters the day of the date (if entered in the correct format). But once they go back to change the date in the ADD_Inc_DATE_TXT textbox, the 'DAY' in the "LBL_Inc_Day_Type" doesn't update with the new change.

    So, would someone know how to resolve the following problem?
    How can I get the label to update the day type (eg. Mon, Tues, Wed... etc.) whenever the ADD_Inc_DATE_TXT textbox is changed?

    Please advise if you need further information.

    Cheers,
    ShyButterfly

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform to show date format in textbox or label
    By coach.32 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-17-2013, 08:55 PM
  2. VBA-EXCEL-TextBox Displaying and manipulating date
    By Yona in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2012, 12:20 PM
  3. Excel 2010 Userform Textbox Word Wrap
    By jwright650 in forum Excel General
    Replies: 3
    Last Post: 12-27-2010, 11:09 AM
  4. userform: trasnferring textbox value to label field in next userform
    By brillison in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-17-2008, 08:18 PM
  5. Displaying Cell Value in UserForm Label
    By Frank & Pam Hayes in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-07-2005, 06:05 AM

Tags for this Thread

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