Hello, what i am tryin to do is generate this report from a form for this telephone company where i input the customers phone no. AND the beginning and end dates to view his billing history ,, what i have now is that it is getting billing history for the specified dates but NOT for a specified customer phone no. here is the VB code :
Private Sub Command4_Click()
Dim strReport As String
Dim strDateField As String
Dim strWhere As String
Dim lngView As Long
Const strcJetDate = "\#mm\/dd\/yyyy\#"
strReport = "CallCostQuery"
strDateField = "[Date]"
lngView = acViewPreview
If Len(Me.Text5 & "") > 0 Then
strWhere = strWhere & " AND [CustomerPhoneno] = '" & Me.Text5 & "'"
End If
If IsDate(Me.txtStartDate) Then
strWhere = "(" & strDateField & " >= " & Format(Me.txtStartDate, strcJetDate) & ")"
End If
If IsDate(Me.txtEndDate) Then
If strWhere <> vbNullString Then
strWhere = strWhere & " AND "
End If
strWhere = strWhere & "(" & strDateField & " < " & Format(Me.txtEndDate + 1, strcJetDate) & ")"
End If
If CurrentProject.AllReports(strReport).IsLoaded Then
DoCmd.close acReport, strReport
End If
DoCmd.OpenReport strReport, lngView, , strWhere
exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Cannot open report"
End If
Resume exit_Handler
End Sub
can anyone please help , am i doing something wrong ?
Private Sub Command4_Click()
Dim strReport As String
Dim strDateField As String
Dim strWhere As String
Dim lngView As Long
Const strcJetDate = "\#mm\/dd\/yyyy\#"
strReport = "CallCostQuery"
strDateField = "[Date]"
lngView = acViewPreview
If Len(Me.Text5 & "") > 0 Then
strWhere = strWhere & " AND [CustomerPhoneno] = '" & Me.Text5 & "'"
End If
If IsDate(Me.txtStartDate) Then
strWhere = "(" & strDateField & " >= " & Format(Me.txtStartDate, strcJetDate) & ")"
End If
If IsDate(Me.txtEndDate) Then
If strWhere <> vbNullString Then
strWhere = strWhere & " AND "
End If
strWhere = strWhere & "(" & strDateField & " < " & Format(Me.txtEndDate + 1, strcJetDate) & ")"
End If
If CurrentProject.AllReports(strReport).IsLoaded Then
DoCmd.close acReport, strReport
End If
DoCmd.OpenReport strReport, lngView, , strWhere
exit_Handler:
Exit Sub
Err_Handler:
If Err.Number <> 2501 Then
MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Cannot open report"
End If
Resume exit_Handler
End Sub
can anyone please help , am i doing something wrong ?