I have a calendar button that the user can select to choose a date on several of my forms. I'm using VBA to tell the calendar form which date to default to, as well as whcih field to send the selected date to. It works perfectly in all spots except one, where the button is on a subform. I have another form with this same button on a subform there and it works correctly. I'm not sure what I'm missing here.
The error I'm getting on clicking the button is "The object you referenced in the Visual Basic procedure as an OLE object isn't an OLE object."
The code that works:
[Global Code].stSelectDate = "DueDate"
If (Eval("[Forms]![OpsProject]![OpsTask].Form!txtDueDate Is Not Null")) Then
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = [Forms]![OpsProject]![OpsTask].Form!txtDueDate
DoCmd.Echo True
Else
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = Now()
DoCmd.Echo True
End If
The code that doesn't work:
[Global Code].stSelectDate = "ConfigDtlsEffDate"
If (Eval("[Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtEffectiveDate Is Not Null")) Then
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = [Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtDueDate
DoCmd.Echo True
Else
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = Now()
DoCmd.Echo True
End If
The error I'm getting on clicking the button is "The object you referenced in the Visual Basic procedure as an OLE object isn't an OLE object."
The code that works:
[Global Code].stSelectDate = "DueDate"
If (Eval("[Forms]![OpsProject]![OpsTask].Form!txtDueDate Is Not Null")) Then
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = [Forms]![OpsProject]![OpsTask].Form!txtDueDate
DoCmd.Echo True
Else
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = Now()
DoCmd.Echo True
End If
The code that doesn't work:
[Global Code].stSelectDate = "ConfigDtlsEffDate"
If (Eval("[Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtEffectiveDate Is Not Null")) Then
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = [Forms]![Config_frm]![ConfigDetailsSub_frm].Form!txtDueDate
DoCmd.Echo True
Else
DoCmd.Echo False, "Visual Basic Code is running."
DoCmd.OpenForm "Calendar", acNormal, "", "", , acNormal
Forms!Calendar!OleCalendar.Value = Now()
DoCmd.Echo True
End If