ChrisLeicester
Member
- Local time
- Today, 11:45
- Joined
- Feb 14, 2025
- Messages
- 42
Hi
I have a continuous form which lists all my transaction and their values.
On the form header I have various text/combo boxes to filter the results and a Command button to filter according to what has been entered in any of the boxes.
The user can enter a date, amount, select a customer etc. Instead of filtering by one box, i want to add the variable and make one STR to use in the filter, so it can be filtered by one of more variables.
I have a vba code that i made that looks at each box and if that box is not null, ie a filter has been entered, it adds the options together to make the filter string. After all boxes have been checked, it then runs the filter.
The VBA crashes at the Me. line and says invalid use of me
Heres my code
i have another form which filters by just one box, and has the same two me. lines at the end (apart from the form name) and it works!
Any ideas why it isnt working in this case.
Thanks
Chris
I have a continuous form which lists all my transaction and their values.
On the form header I have various text/combo boxes to filter the results and a Command button to filter according to what has been entered in any of the boxes.
The user can enter a date, amount, select a customer etc. Instead of filtering by one box, i want to add the variable and make one STR to use in the filter, so it can be filtered by one of more variables.
I have a vba code that i made that looks at each box and if that box is not null, ie a filter has been entered, it adds the options together to make the filter string. After all boxes have been checked, it then runs the filter.
The VBA crashes at the Me. line and says invalid use of me
Heres my code
Code:
Public Function filterRefundList()
Dim FilterSTR As String
FilterSTR = " "
'Start to build filter string for filtering
'Look for entry in date pick textbox
If IsNull([Forms]![RefundSearchSubFM]![DatePicked]) = False Then
FilterSTR = FilterSTR & "TransactionDate = #" & [Forms]![RefundSearchSubFM]![DatePicked] & "#"
End If
'Look for entry in transaction number box
If IsNull([Forms]![RefundSearchSubFM]![TransPicked]) = False Then
FilterSTR = FilterSTR & "And SaleTransactionID = " & [Forms]![RefundSearchSubFM]![TransPicked]
End If
'Look for entry in Customer picked textbox
If IsNull([Forms]![RefundSearchSubFM]![CustomerPicked]) = False Then
FilterSTR = FilterSTR & "And CustomerID = " & [Forms]![RefundSearchSubFM]![CustomerPicked]
End If
'Look for entry in amount picked textbox
If IsNull([Forms]![RefundSearchSubFM]![AmountPicked]) = False Then
FilterSTR = FilterSTR & "And TransTTL = " & [Forms]![RefundSearchSubFM]![AmountPicked]
End If
'Set filter on continuous form
Me.RefundSearchSubFM.Form.Filter = FilterSTR
Me.RefundSearchSubFM.FilterOn = True
End Function
i have another form which filters by just one box, and has the same two me. lines at the end (apart from the form name) and it works!
Any ideas why it isnt working in this case.
Thanks
Chris