I have an Access 2003 linked table. The table is linked to a SQL Server 2005 database table. I have created an Access report using the linked table.
I created a unbound form with one unbound text box field. The user is to put a date in the form's unbound text field ("txt_AppDate"). The form's "txt_AppDate" field is formatted using the "Short Date" format.
After a date is entered in the "txt_AppDate" field, the user selects the "view" command button. I want the report to open showing only the records that have a date greater than or equal to the date entered in the form's "txt_AppDate" field.
When I attempted to do this, using the below code in the command button, II receive a "Type Mismatch" error message. What is wrong?
Private Sub cmd_PrintOnlApps_Click()
On Error GoTo Err_cmd_PrintOnlApps_Click
'Open r_Apps_ONL report using criteria from an unbound Form field
'The User is to enter a date in the unbound form field txt_AppDate
Dim stRptName As String 'Report to open
Dim dtRptField As Date 'The Report's date field
Dim dtFrmDate As Date 'The Form's field containing the user's input date
stRptName = "r_Apps-ONL"
dtRptField = "Reports!" & stRptName & "!date"
dtFrmDate = CDate(Forms!f_PrintAppsFromDate!txt_AppDate)
DoCmd.OpenReport stRptName, acViewPreview, , dtRptField & " >= " & dtFrmDate