Pass an operator through combo box

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
Thank you for your suggestions, it was a great one. with much modification to
it, i was able to run it.

Take care
 
Back
Top