I found some example code to add a popup calendar to a form to allow a user to select a date. I imported the code and forms into my database. I changed the record name to the name of my date field I want populated in the property control. When I changed everything I was suppose to change, I get a type mismatch error. What am I doing wrong? It works in the examble I down loaded. Your help would be appreciated.
This is what I changed in the control for onclick.
=CalendarFor([Opened Date])
Here is the code.
Option Compare Database
Option Explicit
'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the calendar to.
Public Function CalendarFor(txt As TextBox, Optional strTitle As String)
On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to return the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed in OpenArgs).
Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog, OpenArgs:=strTitle
Exit_Handler:
Exit Function
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbExclamation, "CalendarFor()"
Resume Exit_Handler
End Function
This is what I changed in the control for onclick.
=CalendarFor([Opened Date])
Here is the code.
Option Compare Database
Option Explicit
'Calendar form variable:
Public gtxtCalTarget As TextBox 'Text box to return the date from the calendar to.
Public Function CalendarFor(txt As TextBox, Optional strTitle As String)
On Error GoTo Err_Handler
'Purpose: Open the calendar form, identifying the text box to return the date to.
'Arguments: txt = the text box to return the date to.
' strTitle = the caption for the calendar form (passed in OpenArgs).
Set gtxtCalTarget = txt
DoCmd.OpenForm "frmCalendar", windowmode:=acDialog, OpenArgs:=strTitle
Exit_Handler:
Exit Function
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, vbExclamation, "CalendarFor()"
Resume Exit_Handler
End Function