S
Stockwell43
Hello,
I have a form that I type in the data and in the dteail report field made a
copy of the fields from the report. What I want is for the information I
typed in the fields of the form to show on the report when I click the button.
Here is the code behind the button:
Private Sub cmdRunReport_Click()
If Len(Me.Title & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.Title & "*"
End If
If Len(Me.DiscType & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.DiscType & "*"
End If
If Len(Me.CDCatagory & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.CDCatagory & "*"
End If
If Len(Me.CDArtist & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.CDArtist & "*"
End If
If Len(Me.DVDCatagory & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.DVDCatagory & "*"
End If
If Len(Me.DVDActors & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.DVDActors & "*"
End If
****Dim strWhere As String 'String variable to store where clause
If Len(strWhere & "") = 0 Then
' no options selected. Open report with no where condition
DoCmd.OpenReport "rptinventory", acViewPreview
Else
' remove first "AND" from where condition and pass across to report
DoCmd.OpenReport "rptinventory", acViewPreview,
WhereCondition:=Mid(strWhere, 6)
End If
End Sub
The code stops where I placed the **** (not in the code just making it
easier for you to find) and an error comes up saying:
"Duplicate declaration in current scope"
Does anyone know how to fix this? I got it from a site.
Thanks!
I have a form that I type in the data and in the dteail report field made a
copy of the fields from the report. What I want is for the information I
typed in the fields of the form to show on the report when I click the button.
Here is the code behind the button:
Private Sub cmdRunReport_Click()
If Len(Me.Title & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.Title & "*"
End If
If Len(Me.DiscType & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.DiscType & "*"
End If
If Len(Me.CDCatagory & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.CDCatagory & "*"
End If
If Len(Me.CDArtist & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.CDArtist & "*"
End If
If Len(Me.DVDCatagory & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.DVDCatagory & "*"
End If
If Len(Me.DVDActors & "") > 0 Then
strWhere = strWhere & " AND textfield LIKE " & Me.DVDActors & "*"
End If
****Dim strWhere As String 'String variable to store where clause
If Len(strWhere & "") = 0 Then
' no options selected. Open report with no where condition
DoCmd.OpenReport "rptinventory", acViewPreview
Else
' remove first "AND" from where condition and pass across to report
DoCmd.OpenReport "rptinventory", acViewPreview,
WhereCondition:=Mid(strWhere, 6)
End If
End Sub
The code stops where I placed the **** (not in the code just making it
easier for you to find) and an error comes up saying:
"Duplicate declaration in current scope"
Does anyone know how to fix this? I got it from a site.
Thanks!