Hello Guys,
I attempting to develop a code that generates a report via a form with text, numeric, and yes/no fields where the user can enter desired parameters in the form and click the "btnReport" button. It works for the text fields, but I don't know how to alter the code to work for numeric, and yes/no fields. Can someone help?
Here is what I have for the text fields
I'm pretty sure that the only part of this code that needs to be edited is the following:
But how do I edit it to deal with numeric fields and yes/no fields?
I attempting to develop a code that generates a report via a form with text, numeric, and yes/no fields where the user can enter desired parameters in the form and click the "btnReport" button. It works for the text fields, but I don't know how to alter the code to work for numeric, and yes/no fields. Can someone help?
Here is what I have for the text fields
Code:
Private Sub btnReport_Click()
On Error GoTo Err_btnReport_Click
'Button filters out records depending on the criteria entered in the search fields
Dim strWhere As String
Dim lngLen As Long
Dim stDocName As String
'Stores the search criteria and enters it into the Where Condition
If Not IsNull([Forms]![frmIncident]![tbo1]) Then
strWhere = "([tbo1] = [Forms]![frmIncident]![tbo1]) And "
End If
'This is used to cut off the " AND " at the end of the Where Condition
lngLen = Len(strWhere) - 5
'If there was no information included in the criteria fields an error pops up, otherwise the search processes the Where Condition
If lngLen <= 0 Then
MsgBox "Please enter search criteria!"
Else
strWhere = Left$(strWhere, lngLen)
stDocName = "rptReport"
DoCmd.OpenReport stDocName, acPreview, , strWhere
End If
'this prevents the form from developing a new record
Form.Undo
Exit_btnReport_Click:
Exit Sub
Err_btnReport_Click:
MsgBox Err.Description
Resume Exit_btnReport_Click
End Sub
I'm pretty sure that the only part of this code that needs to be edited is the following:
Code:
If Not IsNull([Forms]![frmIncident]![tbo1]) Then
strWhere = "([tbo1] = [Forms]![frmIncident]![tbo1]) And "
But how do I edit it to deal with numeric fields and yes/no fields?