|
-
Apr 12th, 2004, 05:17 AM
#1
Thread Starter
New Member
Filter Question
Hi guys.
Currently I have an application which holds orders. To search through the orders, I use a filter which the user activates to limit the orders he can move through in the dataset. The code to do so is as follows:
Private Sub btn_filter_Click()
Dim str_filter As String
str_filter = ""
'Put the filter on depending on what fields are filled out
If (Trim(txt_find_Order) <> "") Then
str_filter = str_filter + "Order_no like '*" & txt_find_Order & "*' And "
End If
If (Trim(cmb_find_status) <> "") Then
str_filter = str_filter + "cur_status like '*" & cmb_find_status & "*' And "
End If
'remover the last ' And '
If (str_filter <> "") Then
str_filter = Left(str_filter, (Len(str_filter) - 5))
End If
MsgBox str_filter
ado_rmOrder.Filter = str_filter
Else ....
So when the filter is on, the user moves through records set in the filter text boxes. the beauty of this is that the wildcards (*) mean you can only enter part of a number and it leave any orders in the recordset that have part of it match the number. For example if the order number filter is set to "123" then order numbers "12345", "45123", "3412363" and "123" will all pass through the filter.
The problem is I also want to filter on a time / date field. This requires hases (#) as follows:
If (Trim(txt_find_date) <> "") Then
str_filter = str_filter + "Order_Date like #" & txt_find_date & "# And "
End If
The problem is that I cannot seem to insert wildcards (*) in this statement. This means that the filter will discard all records that dont EXACTLY match the txt_find_date field. This means if txt_find_date = 12/12/03, then a record with "12/12/03 12:47:32 PM" with be rejected by the filter, as it is not an EXACT match. As you can imagine, this is not much good to me. So my question is, is there any way to get some form of wildcards working with date fields so that I can filter records based on only part of the date field?
Cheers
Frank
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|