+ Reply to Thread
Results 1 to 5 of 5

Date doesn't appear automatically when running date code

  1. #1
    Registered User
    Join Date
    07-07-2009
    Location
    Wilkie, Saskatchewan
    MS-Off Ver
    Excel 2003
    Posts
    21

    Date doesn't appear automatically when running date code

    Private Sub txttodaysdate_change()

    txttodaysdate = Format(Now, "mmm/d/yy")

    End Sub

    when i use this code i wnat the date to automatically appear in the text box but it doesn't I have type something into the textbox then the current date appears, any help would be great.
    Last edited by James12; 08-21-2009 at 05:21 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Date doesn't appear automatically when running date code

    Hi James,

    Notice the "txttodaysdate_change()" bit. That means the code will only run when you make a change to that textbox.

    If you want it to update for some other reason or when some other event happens, let us know the details..

  3. #3
    Registered User
    Join Date
    07-07-2009
    Location
    Wilkie, Saskatchewan
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Date doesn't appear automatically when running date code

    THis code is enbedded in a user form I would like the current date textbox to have the current date appear when the user form is opened. I kind of thought it might be the chnage but I am just learning how to write code and no ttotally sure of what I am doing.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Date doesn't appear automatically when running date code

    Ah, to get it to happen when the form opens, you have to reference the Forms "Initialize" event, like so:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-07-2009
    Location
    Wilkie, Saskatchewan
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Date doesn't appear automatically when running date code

    thansk Paul works awesome I will mark post as solved

+ 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