J
John F
Access 2003
I have a form, frmExample that has a query, qryTestQuery, as the Record
Source.
I copied the SQL from the SQL view into a string:
strTAFormQuery = "SELECT ….. “ _
& "FROM …" _
& "ORDER BY "
Then in respond to a command button on the form, I want to sort by a
different field:
CurrentDb.QueryDefs("qryTestQuery").SQL = strTAFormQuery & "tblTAData.chrIPT;"
Me.Requery
The problem is Me.Requery has no effect. I think the query is being
resorted because if I open the query directly, it shows the updated sort, but
the records on frmExample are not resorted.
What should I do to make the records on the form reflect the new sort?
------------------
I also use the filter property of the form. In case that was interfering
with the above, I tested this possibility by turning off the filter, but that
had no effect. Is it ok to continue to use the filter property instead of
including a WHERE clause in the SQL string? It would be more convenient for
me as there are several conditions setting the filter and I would rather
leave that alone.
------------------
Another question, if I want to sort by another field that has specific text
values, e.g. “Excellentâ€, “Goodâ€, “Fairâ€, “Poor†is there a way to define the
order of sorting, versus alphabetic?
Thanks,
John
I have a form, frmExample that has a query, qryTestQuery, as the Record
Source.
I copied the SQL from the SQL view into a string:
strTAFormQuery = "SELECT ….. “ _
& "FROM …" _
& "ORDER BY "
Then in respond to a command button on the form, I want to sort by a
different field:
CurrentDb.QueryDefs("qryTestQuery").SQL = strTAFormQuery & "tblTAData.chrIPT;"
Me.Requery
The problem is Me.Requery has no effect. I think the query is being
resorted because if I open the query directly, it shows the updated sort, but
the records on frmExample are not resorted.
What should I do to make the records on the form reflect the new sort?
------------------
I also use the filter property of the form. In case that was interfering
with the above, I tested this possibility by turning off the filter, but that
had no effect. Is it ok to continue to use the filter property instead of
including a WHERE clause in the SQL string? It would be more convenient for
me as there are several conditions setting the filter and I would rather
leave that alone.
------------------
Another question, if I want to sort by another field that has specific text
values, e.g. “Excellentâ€, “Goodâ€, “Fairâ€, “Poor†is there a way to define the
order of sorting, versus alphabetic?
Thanks,
John