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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Control

Status
Not open for further replies.

glenellis

IS-IT--Management
Jul 20, 2001
12
0
0
US
Is it possible to display a date in a text box (04/24/02) and give the user the capability to double-click on that box to invoke a Calendar control, where they could then navigate to their desired date.
It appears to me that when you use just the Calendar control the "box" is very large and takes up lots of room on the screen, hence my question about starting out with a small text box.

Thanks for your help.
 
You just need to create a form where you will place a calendar control on it. Then, from the other form where you have your desirable textbox, load from the textbox dblclick event the form for the calendar. Then take the date value from the calendar an place it in the text box.

Private Sub text1_DblClick()

Load frmCalendar
frmCalendar.Show vbModal
Set frmCalendar = Nothing

End Sub


Hope this help
Calendar

Private Sub Form_Load()

calDateLookup.Value = form1.text1.Text

End Sub

Private Sub cmdOk_Click()

Dim strDate As String

strDate = calDateLookup.Value

form1.text1.Text= strDate

Unload Me

End Sub


 
I have the Form_Load & Click events tied to the Calendar form. When I run I get an error on the calDateLookup.Value = form1.text1.Text line - Error 424 Object required???
 
It's all depend on the name of the control....

your the one who precise the name of your control.

 
Another approach is to place the Calendar Control on the main form, but set its visible property to False.

Then in your DoubleClick event, do the following:

Sub txtBox_DblClick

calControl.visible = True
If (IsValidDate(txtBox.Text)) Then
calControl.Value = txtBox.Text
Else
calControl.Value = Date
End If
calControl.SetFocus

End Sub

Then add the following event handlers for the calendar control. If you have turned CausesValidation off for some control, you may also want to include a lost_focus handler.

Private Sub calControl_DateClick(ByVal DateClicked As Date)

txtBox.Text = Format(DateClicked, "mm/dd/yyyy")

Exit Sub

Private Sub calControl_Validate(Cancel As Boolean)

calControl.Visible = False

End Sub
Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top