Hey I need a little help,
I have create a calendar form in my database. This calendar form is just a form with an activeX calendar object. I want to use this form with the activeX calendar object to pass dates to fields in another form. For example, in my form Projects, I have 4 date fields: "StartDate", "EstimatedClosedDate", "CloseDate", and "TerminatedDate". I would like to call my calendar form on clicking in any one of these fields, select a date, and have the date passed into the field. I do have the form working for only the "TerminatedDate" field. I cannot figure out how to get the calendar form to recognize which field to pass the date back into. Here is my code:
Calendar_Form:
Dim txtObject As TextBox
Private Sub cmdCancel_Click()
'Cancel and close form
DoCmd.Close acForm, "Calendar"
End Sub
Private Sub cmdSet_Click()
On Error GoTo ErrHandler
Set txtObject = [Form_Projects Sub].TerminatedDate
txtObject = CalObject.Value
txtObject.SetFocus
'close form
DoCmd.Close acForm, "Calendar"
CleanUpAndExit:
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume CleanUpAndExit
End Sub
Private Sub Form_Load()
'This code must be placed in the Load event to work properly
'DO NOT move to the Open event
CalObject.Value = GCalDate
CalObject.Value = Date
DoCmd.RepaintObject acForm, "Calendar"
End Sub
Project_Form:
Private Sub TerminatedDate_Click()
GetDate Me.TerminatedDate
DoCmd.OpenForm "Calendar", acNormal, , , acFormAdd, acDialog
[Forms]![Calendar].SetFocus
End Sub
Private Sub StartDate_Click()
GetDate Me.TerminatedDate
DoCmd.OpenForm "Calendar", acNormal, , , acFormAdd, acDialog
[Forms]![Calendar].SetFocus
End Sub
I have create a calendar form in my database. This calendar form is just a form with an activeX calendar object. I want to use this form with the activeX calendar object to pass dates to fields in another form. For example, in my form Projects, I have 4 date fields: "StartDate", "EstimatedClosedDate", "CloseDate", and "TerminatedDate". I would like to call my calendar form on clicking in any one of these fields, select a date, and have the date passed into the field. I do have the form working for only the "TerminatedDate" field. I cannot figure out how to get the calendar form to recognize which field to pass the date back into. Here is my code:
Calendar_Form:
Dim txtObject As TextBox
Private Sub cmdCancel_Click()
'Cancel and close form
DoCmd.Close acForm, "Calendar"
End Sub
Private Sub cmdSet_Click()
On Error GoTo ErrHandler
Set txtObject = [Form_Projects Sub].TerminatedDate
txtObject = CalObject.Value
txtObject.SetFocus
'close form
DoCmd.Close acForm, "Calendar"
CleanUpAndExit:
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume CleanUpAndExit
End Sub
Private Sub Form_Load()
'This code must be placed in the Load event to work properly
'DO NOT move to the Open event
CalObject.Value = GCalDate
CalObject.Value = Date
DoCmd.RepaintObject acForm, "Calendar"
End Sub
Project_Form:
Private Sub TerminatedDate_Click()
GetDate Me.TerminatedDate
DoCmd.OpenForm "Calendar", acNormal, , , acFormAdd, acDialog
[Forms]![Calendar].SetFocus
End Sub
Private Sub StartDate_Click()
GetDate Me.TerminatedDate
DoCmd.OpenForm "Calendar", acNormal, , , acFormAdd, acDialog
[Forms]![Calendar].SetFocus
End Sub