I am attempting to evaluate what my user has inputed in the fields availabe on my form [frmQuery]. The two available fields are [dtmBeg] and [dtmEnd].
Here is the code:
I was hoping someone could help me decifer what it is that I am doing incorrectly here. Basically what I am looking for are the following conditions:
Null Beginning Date queries records before the end date
Null End Date queries records after beginning date
no null fields queries records between beginning and end date
If someone can help with this task I would appreciate it. Thanks!
Here is the code:
Code:
Option Compare Database
Option Explicit
Public stDocName As String
stDocName = ""
Private Sub btnPreview_Click()
On Error GoTo Err_btnPreview_Click
stDocName = Evaluate()
Dim stPreview As String
stPreview = stDocName
DoCmd.OpenReport stPreview, acPreview
Exit_btnPreview_Click:
Exit Sub
Err_btnPreview_Click:
MsgBox Err.Description
Resume Exit_btnPreview_Click
End Sub
Public Sub Evaluate()
If IsNull(Me.dtmBeg) And IsNull(Me.dtmEnd) Then
stDocName = "rptPQ_CPSAll"
Else
If IsNull(Me.dtmBeg) And Not IsNull(Me.dtmEnd) Then
stDocName = "rptPQ_CPSUpTo"
Else
If Not IsNull(Me.dtmBeg) And IsNull(Me.dtmEnd) Then
stDocName = "rptPQ_CPSAfter"
Else
stDocName = "rptPQ_CPSBetween"
End If
End If
End If
End Sub
I was hoping someone could help me decifer what it is that I am doing incorrectly here. Basically what I am looking for are the following conditions:
Null Beginning Date queries records before the end date
Null End Date queries records after beginning date
no null fields queries records between beginning and end date
If someone can help with this task I would appreciate it. Thanks!