Solved

Calendar1

Posted on 2001-09-11
3
286 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now