A
Alex
I have the following code in a form button. Although I need to use the
Location field and Date field as the report filter, I don't want to see them
in my report (which is actually a chart pasted into a report). How can I
write the below code so that I can use Location and Date as the
parameters/filter below, but now show them in report (chart)? Thanks
Private Sub cmdChart_Click()
Dim VarItem As Variant
Dim strStore As String
Dim strLocation As String
Dim datBeginDate As Date
Dim datEndDate As Date
Dim strFilter As String
' Build criteria string from StoreRoom listbox
For Each VarItem In Me.cmdStoreRoom.ItemsSelected
strStore = strStore & ",'" & Me.cmdStoreRoom.ItemData(VarItem) _
& "'"
Next VarItem
If Len(strStore) = 0 Then
strStore = "Like '*'"
Else
strStore = Right(strStore, Len(strStore) - 1)
strStore = "IN(" & strStore & ")"
End If
' Build criteria string from Location option group
Select Case Me.cmdLocation.Value
Case 1
strLocation = "='1'"
Case 2
strLocation = "='2'"
End Select
'Build Beginning & Ending date parameter
If Not IsNull(Me.cmdBeginDate) Then
datBeginDate = Me.cmdBeginDate
End If
If Not IsNull(Me.cmdEndDate) Then
datEndDate = Me.cmdEndDate
End If
' Build filter string
strFilter = "[StorageRoom] " & strStore & " AND [Location] " &
strLocation & " AND [Date] Between #" & datBeginDate & "# and #" & datEndDate
& "#"
' Apply the filter and switch it on
With Reports![LocationsChartbyStorage]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Location field and Date field as the report filter, I don't want to see them
in my report (which is actually a chart pasted into a report). How can I
write the below code so that I can use Location and Date as the
parameters/filter below, but now show them in report (chart)? Thanks
Private Sub cmdChart_Click()
Dim VarItem As Variant
Dim strStore As String
Dim strLocation As String
Dim datBeginDate As Date
Dim datEndDate As Date
Dim strFilter As String
' Build criteria string from StoreRoom listbox
For Each VarItem In Me.cmdStoreRoom.ItemsSelected
strStore = strStore & ",'" & Me.cmdStoreRoom.ItemData(VarItem) _
& "'"
Next VarItem
If Len(strStore) = 0 Then
strStore = "Like '*'"
Else
strStore = Right(strStore, Len(strStore) - 1)
strStore = "IN(" & strStore & ")"
End If
' Build criteria string from Location option group
Select Case Me.cmdLocation.Value
Case 1
strLocation = "='1'"
Case 2
strLocation = "='2'"
End Select
'Build Beginning & Ending date parameter
If Not IsNull(Me.cmdBeginDate) Then
datBeginDate = Me.cmdBeginDate
End If
If Not IsNull(Me.cmdEndDate) Then
datEndDate = Me.cmdEndDate
End If
' Build filter string
strFilter = "[StorageRoom] " & strStore & " AND [Location] " &
strLocation & " AND [Date] Between #" & datBeginDate & "# and #" & datEndDate
& "#"
' Apply the filter and switch it on
With Reports![LocationsChartbyStorage]
.Filter = strFilter
.FilterOn = True
End With
End Sub