Solved

Calendar1

Posted on 2001-09-11
3
290 Views
Last Modified: 2008-03-06
I have the Calendar1 control on my form and when a textbox gets focus the calendar comes up. I would like it to display todays date, not a hard coded date.
Can this be done, if so how?

Thanks
0
Comment
Question by:mscala
3 Comments
 
LVL 1

Expert Comment

by:baltman
ID: 6474387
You can do this by setting the properties for the calendar when the form loads (or on any action you choose). I will use the example when the form loads:

Private Sub Form_Load()
  Calendar1.Day = dayNow
  Calendar1.Month = monthNow
  Calendar1.Year = yearNow
End Sub

You would have to assign the values to dayNow, monthNow and yearNow with the Date function.

Hope this helps.

BA
0
 
LVL 10

Accepted Solution

by:
Eduard Ghergu earned 10 total points
ID: 6474451
Private Sub Form_Load()
  Calendar1.Value = Now
End Sub
0
 
LVL 27

Expert Comment

by:planocz
ID: 6474485
you can also use the format statement to view in your textbox....

calendar1.Value = now
text1.text = format(calendar1.Value, "mm/dd/yyyy")
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question