CuriousGeorge
Registered User.
- Local time
- Tomorrow, 00:08
- Joined
- Feb 18, 2011
- Messages
- 131
Hello,
im trying to get my filter button to work.
On my form i have a list box and i would like to filter the items that are listed there with help from three combo boxes, combodate1 combodate2 and combotype.
The listbox is using Query1 to list items so i thought i could go on using something like the code below for my filterbutton.
I dont know though how to set the "SET part" on the UPDATE expression.
If the box lists the following:
SomeDate 2010-12-12 TypeOfFile 000001-D00
SomeDate 2010-12-25 TypeOfFile 000001-D00
SomeDate 2011-01-01 TypeOfFile 000002-D00
And combodate1 box is 2010-12-12. combodate2 is 2010-12-25 and combotype is *00 i want it to filter within that range and display the upper two rows.
I mean if I would use the syntax 'SET Query1.TypeOfFile = [Forms]![frm]![ComboType]' it would set that to either D00,D01,D02,D03,D04 since im using the LIKE identifier in that combo box to ident files with those extensions. I want to filter on one of those types but i want the listbox to display all files that have that extension.
How do i handle the SET part here? Is it possible to use the LIKE operator here as well? How do i set SET when im using a range of dates from the other two combo boxes?
Maybe im totally off here...
Thanks v much
im trying to get my filter button to work.
On my form i have a list box and i would like to filter the items that are listed there with help from three combo boxes, combodate1 combodate2 and combotype.
The listbox is using Query1 to list items so i thought i could go on using something like the code below for my filterbutton.
I dont know though how to set the "SET part" on the UPDATE expression.
If the box lists the following:
SomeDate 2010-12-12 TypeOfFile 000001-D00
SomeDate 2010-12-25 TypeOfFile 000001-D00
SomeDate 2011-01-01 TypeOfFile 000002-D00
And combodate1 box is 2010-12-12. combodate2 is 2010-12-25 and combotype is *00 i want it to filter within that range and display the upper two rows.
I mean if I would use the syntax 'SET Query1.TypeOfFile = [Forms]![frm]![ComboType]' it would set that to either D00,D01,D02,D03,D04 since im using the LIKE identifier in that combo box to ident files with those extensions. I want to filter on one of those types but i want the listbox to display all files that have that extension.
How do i handle the SET part here? Is it possible to use the LIKE operator here as well? How do i set SET when im using a range of dates from the other two combo boxes?
Maybe im totally off here...
Thanks v much
Code:
Private Sub FilterLoadedFiles_Click()
Dim qdf As DAO.QueryDef
Dim s As String
Dim specname As String
specname = "ExportSpecs"
s = "UPDATE Query1.TypeOfFile, Query1.SomeDate FROM Query1 SET Query1.TypeOfFile = ???, Query1.SomeDate = ??? WHERE (((Query1.SomeDate)>=[Forms]![frm]![ComboDate1] AND ((Query1.SomeDate)<=[Forms]![frm]![ComboDate2])) AND ((Query1.TypeOfFile) LIKE [Forms]![frm]![ComboType]));"
Debug.Print s
Set qdf = CurrentDb.QueryDefs("Query1")
qdf.Sql = s
DoCmd.OpenQuery ("Query1")
End Sub
Last edited: