R
Renae
I have set the table field up as at dd/mm/yyyy
(australian) and have set this up also in the visual basic
however I am getting Syntax Error. Here is what I have:
Have I done something wrong?
Private Sub Ok_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for
OpenReport.
Const conDateFormat = "\#dd\/mm\/yyyy\#"
strReport = "Expense Report"
strField = "Expense Date"
If IsNull(Me.txtstartdate) Then
If Not IsNull(Me.txtenddate) Then 'End date, but
no start.
strWhere = strField & " < " & Format
(Me.txtenddate, conDateFormat)
End If
Else
If IsNull(Me.txtenddate) Then 'Start date,
but no End.
strWhere = strField & " > " & Format
(Me.txtstartdate, conDateFormat)
Else 'Both start
and end dates.
strWhere = strField & " Between " & Format
(Me.txtstartdate, conDateFormat) _
& " And " & Format(Me.txtenddate,
conDateFormat)
End If
End If
' Debug.Print strWhere 'For
debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
Thanks
Renae
(australian) and have set this up also in the visual basic
however I am getting Syntax Error. Here is what I have:
Have I done something wrong?
Private Sub Ok_Click()
Dim strReport As String 'Name of report to open.
Dim strField As String 'Name of your date field.
Dim strWhere As String 'Where condition for
OpenReport.
Const conDateFormat = "\#dd\/mm\/yyyy\#"
strReport = "Expense Report"
strField = "Expense Date"
If IsNull(Me.txtstartdate) Then
If Not IsNull(Me.txtenddate) Then 'End date, but
no start.
strWhere = strField & " < " & Format
(Me.txtenddate, conDateFormat)
End If
Else
If IsNull(Me.txtenddate) Then 'Start date,
but no End.
strWhere = strField & " > " & Format
(Me.txtstartdate, conDateFormat)
Else 'Both start
and end dates.
strWhere = strField & " Between " & Format
(Me.txtstartdate, conDateFormat) _
& " And " & Format(Me.txtenddate,
conDateFormat)
End If
End If
' Debug.Print strWhere 'For
debugging purposes only.
DoCmd.OpenReport strReport, acViewPreview, , strWhere
End Sub
Thanks
Renae