Hello there, i am trying to run an sql command applying conditions which are selected from the interface. (Access VBA 03)


rst.Open "SELECT * FROM [Contact 2]WHERE [ActAge] " & Combo8.ItemData(Combo8.ListIndex) & " '" & Me.Text2 & "' ", CurrentProject.AccessConnection, adOpenDynamic, adLockOptimistic


Combo8.ItemData(Combo8.ListIndex) >> conditions (e.g '<', '<', '=', 'LIKE'...)

all the conditions stated above works fine, except for 'between'.

if user were to select 'between' in the combo box as the condition, and enters '20 AND 30' (Me.Text2)...

it prompts an error [Between operatator without And in quer expression '[ActAge] between '20 AND 30".]

how i can allow the sql command to read 'AND' from me.text2.

i am trying to string me.text2 into an array and make use of splitstring reading 'AND'.

I suppose there might be an alternate method or some syntax adjustments.

Thank You

Astro