Pass an operator through combo box

G

Guest

Hi
I am would like to know if there is away to be able to pass ">" operator to
a query through a combo box, all my attempts has failed or got me null
results.
I am using it to generate reports for dates that people need, my purpose is
to be able to get the query to output dates bellow Date() or above Date().
I have tried to pass the whole string >Date() or <Date() to query but did
not work.

Combobox name: dd
Value list: Trained, Not Trained

I have tried value list with an Afterupdate event procedure

Private Sub dd_AfterUpdate()
If Me.dd = "trained" Then
Me.dd = "> Date()"
Else
Me.dd = "< Date()"
End If
End Sub


Yet it did not work
I do not want to write to queries since other forms and reports are directly
related to this query’s output.

Thanks.
 
G

Guest

You can change the SQL of the query according to your selection

Private Sub dd_AfterUpdate()
If Me.dd = "trained" Then
application.CurrentDb.QueryDefs("QueryName").SQL="Select * From TableName
Where FieldName > Date()"
Else
application.CurrentDb.QueryDefs("QueryName").SQL="Select * From TableName
Where FieldName < Date()"
End If
End Sub
 
G

Guest

Thank you for your suggestions, it was a great one. with much modification to
it, i was able to run it.

Take care
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top