arcticsponge
VB makes me crazy
- Local time
- Today, 12:29
- Joined
- Oct 20, 2009
- Messages
- 12
Hi everyone.
First, please accept my apologies if this has been posted in the wrong section.
I am certain that there is a far more easier way to do this, I am open to suggestion but please humour me; its driving me potty!
My database is used for vehicle lookups:
main table: tblItems: fields [type; body; doors; transmission; fuel]
created as INTO from qrySearch: tblSearch: fields [as tblItems]
query: qrySearch: fields [as tblItems]; criteria [type]=key1(), [body]=key2(), [doors]=key3(), [transmission]=key4(), [fuel]=key5()
There will eventually be more fields but for the time being I am only playing with 5 fields / keys
Purpose, I have a listbox bound to tblSearch with OnDoubleClick set to goto record.
To aid filtering, I have a set of checkboxes linked to global code, the same code that runs the criterion of qrySearch:
5 global variables (only displaying 1 - you get the picture)
with the code behind the submit button being:
The problem: I cannot figure out the correct syntax to be passed to the global variable: such as using the wildcard: LIKE "*"; or where multiple selections are required such as "diesel" OR "petrol".
Apologies for the long post.
First, please accept my apologies if this has been posted in the wrong section.
I am certain that there is a far more easier way to do this, I am open to suggestion but please humour me; its driving me potty!
My database is used for vehicle lookups:
main table: tblItems: fields [type; body; doors; transmission; fuel]
created as INTO from qrySearch: tblSearch: fields [as tblItems]
query: qrySearch: fields [as tblItems]; criteria [type]=key1(), [body]=key2(), [doors]=key3(), [transmission]=key4(), [fuel]=key5()
There will eventually be more fields but for the time being I am only playing with 5 fields / keys
Purpose, I have a listbox bound to tblSearch with OnDoubleClick set to goto record.
To aid filtering, I have a set of checkboxes linked to global code, the same code that runs the criterion of qrySearch:
5 global variables (only displaying 1 - you get the picture)
Code:
Public Function key2() As String
key2 = strKey2
End Function
Code:
Private Sub Command235_Click()
DoCmd.SetWarnings False
Dim strType As String
Dim strBody As String
Dim strDoors As String
Dim strTransmission As String
Dim strFuel As String
strKey1 = like "*" 'car / van
strKey2 = like "*" 'saloon / hatch / pickup
strKey3 = like "*" '3 / 5
strKey4 = like "*" 'auto / semi / manual
strKey5 = like "*" 'Diesel / petrol / gas
If Me.Check1 = True Then strKey1 = "car"
If Me.Check2 = True Then strKey1 = "van"
If Me.Check3 = True Then strKey2 = "saloon or hatch or coupe"
If Me.Check4 = True Then strKey2 = "pickup or small or large"
If Me.Check5 = True Then strKey3 = 3
If Me.Check6 = True Then strKey3 = 5
If Me.Check7 = True Then strKey4 = "auto"
If Me.Check8 = True Then strKey4 = "semi"
If Me.Check9 = True Then strKey4 = "manual"
If Me.Check10 = True Then strKey5 = "Diesel or petrol"
If Me.Check11 = True Then strKey5 = "gas or electric"
DoCmd.OpenQuery "qrySearch", acViewNormal
DoCmd.SetWarnings True
Me.Requery
end sub
Apologies for the long post.