Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set calendar to update field with todays date 1

Status
Not open for further replies.

jjdoro

Technical User
Nov 24, 2002
16
US
I have a date picker calendar that is on a command button and is used to select a date for an Access text box form field that sits next to it. It works fine except that I would like to have it open and update that field to todays date. I tried setting the default value of the field to = Date() but it only opens with the last date that was set on that field. Below is the code for the module of the calendar date picker.
Also on the command button I have the on click event set to =OpenCalendar("zSetReportCriteria","Report Start",10.59,7). zSetReportCriteria is the name of the form and Report Start is the name of the field that gets updated. Any ideas [flush2]


Option Compare Database

Dim ctrl As Control
Dim frm As Form
Const centimeter = 567

Function OpenCalendar(strForm As String, strCtrl As String, intLeft, intTop)
Set frm = Forms(strForm)
Set ctrl = frm(strCtrl)
frm("msCal").Visible = True
frm("msCal").Left = intLeft * centimeter
frm("msCal").Top = intTop * centimeter
frm("msCal").Value = Date
End Function

Function CloseCalendar()
frm(ctrl.Name).SetFocus
frm("msCal").Visible = False
End Function

Sub SetDate()
frm(ctrl.Name).Value = frm("msCal").Value
frm(ctrl.Name).SetFocus
frm("msCal").Visible = False
End Sub
 
When you created the textobx, you must have made a mistake.

Where did you try to set the default value?

To make your control show today's date, go to the design view of the control you want to set for today's date.

(Let's call that control--a text box--txtTodaysDate.)

Click into the control (i.e., the text box named TodaysDate).

Right click and get the control's properties. On the format tab of the properties window, click format and choose the format you want (e.g., short date). Under the data tab, pick the correct control source. (The source will be a date field you have put into a table.)

If you want to get fancy on a short date under the format tab, go to the input mask and type in 99/99/00;0.





Judge Hopkins


There are only two rules for success: (1) Never tell everything you know.
 
Thank you Judge you have been most helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top