Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Calendar Control 10...setting a default value

Posted on 2005-03-25
6
Medium Priority
?
2,173 Views
Last Modified: 2008-01-09
Can the calendar control be set so that by default it displays the current date? I put one into a form I'm working on and everytime I open it it highlights 3/23/05 (the creation date). I cant use a hard value because I want it to display the current date as a default. It is being used to select a day to pull a report from and the most common is current day. I tried putting date() in value property...no go oon that. Did not see a default value area or anything. Please help!!! Thanks!
0
Comment
Question by:dbase118
6 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 13630281
You could programmatically set it in the form's Open event (or better yet, ditch the Calendar control completely and write your own :-)
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13630308
On my form, I did it like this:

Me.Calendar4.Value = "4/1/1985"

You can set the value, for example, in the form's OnLoad event:

Private Sub Form_Load()

Me.MyCalendarControl.Value = "4/1/1985"

End Sub

Additionally, look in the object browser for the different methods associated with the control.  There are methods to increment the day, month, or year, or even set the control to today's date.
0
 
LVL 15

Author Comment

by:dbase118
ID: 13630311
"You could programmatically set it in the form's Open event (or better yet, ditch the Calendar control completely and write your own :-)"----Im afraid I am programmatically challenged.

I actually did try setting it OnOpen but he problem with setting the value is that once it was written into the Value property, I could not change by clicking a new date.
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 500 total points
ID: 13630322
CalendarControlName = Date()

in form's Open event as stated above.
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 13630412
Try this:

1) Create a new form.  Place a calendar control (called MyCalendar) and a command button (called MyButton) on the form.
2) For the button, right click, and select "Build Event.."  When you get to the code window, make sure you are editing the OnClick event.
3) Make the event look exactly like what is shown below:

Private Sub MyButton_Click()   '<--- If you named your button differently, this line should reflect YOUR button's name
Me.MyCalendar.Value = "4/1/1985"
End Sub

4) Run the form.  Select a date on the calendar control.  Click the button.  Select a date.  Click the button.  So on.  Understand?
0
 
LVL 15

Author Comment

by:dbase118
ID: 13630746
Thanks for the help....Gave you both points. In actuality...I had the right idea all along but before I could set the value in the On Open. I had to change the ValueIsNull property to yes or the OnOpen would not overwrite. So It was essentially
something like

Forms![EOD Report Log].Calendar2.Value=date
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Implementing simple internal controls in the Microsoft Access application.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses

577 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