orderby works with yes/no fields?

  • Thread starter GIL-PT via AccessMonster.com
  • Start date
G

GIL-PT via AccessMonster.com

I have a form that shows the result of a query, now i want to be able to sort
the records clicking in the labels of each field everything works great
except with the fields that are (yes/no) when i try to run these i got o pop
up message asking a parameter for the field.

Anybody now why this? How can i work around this?

here is my code:
The "Left" Field is a Yes or No, the others work fine except this one.

Private Sub Left_Label_DblClick(Cancel As Integer)
Forms("RUNS Status").OrderBy = "
"
Forms("RUNS Status").OrderByOn = True
End Sub

Private Sub run_id_Label_DblClick(Cancel As Integer)
Forms("RUNS Status").OrderBy = "[run id]"
Forms("RUNS Status").OrderByOn = True
End Sub

Private Sub TIME_Label_DblClick(Cancel As Integer)
Forms("RUNS Status").OrderBy = "[time]"
Forms("RUNS Status").OrderByOn = True
End Sub​
 
A

Allen Browne

You can sort by yes/no fields. True (-1) sorts before False (0).

You can only sort by field names, so presumably you have fields named left,
run id, and time. Time is a reserved word in VBA (for the system time), and
in JET. Left is also the property of controls on your form, as well as a
reserved word in JET. There is therefore a good chance that Access won't
understand what you intend.

Additionally, Access has to save any edits in progress before it can sort
the form for you. You probably want to add this line to the top of each
procedure to explicitly save:
If Me.Dirty Then Me.Dirty = False

Then rename the fields in your tables and queries, and change the Name and
Control Source of the controls on your form. You should then be able to
sort.

For a list of the field names that will give you problems, see:
Problem names and reserved words in Access
at:
http://allenbrowne.com/AppIssueBadWord.html
There's quite a few of them, so you probably want to use the list as a
reference when making fields rather than try to remember them all.
 
G

GIL-PT via AccessMonster.com

Thank You Allen
I didn't remenber about "conflict names" for the fields, maybe this is the
problem i'm going to try that.


Allen said:
You can sort by yes/no fields. True (-1) sorts before False (0).

You can only sort by field names, so presumably you have fields named left,
run id, and time. Time is a reserved word in VBA (for the system time), and
in JET. Left is also the property of controls on your form, as well as a
reserved word in JET. There is therefore a good chance that Access won't
understand what you intend.

Additionally, Access has to save any edits in progress before it can sort
the form for you. You probably want to add this line to the top of each
procedure to explicitly save:
If Me.Dirty Then Me.Dirty = False

Then rename the fields in your tables and queries, and change the Name and
Control Source of the controls on your form. You should then be able to
sort.

For a list of the field names that will give you problems, see:
Problem names and reserved words in Access
at:
http://allenbrowne.com/AppIssueBadWord.html
There's quite a few of them, so you probably want to use the list as a
reference when making fields rather than try to remember them all.
I have a form that shows the result of a query, now i want to be able to
sort
[quoted text clipped - 22 lines]
Forms("RUNS Status").OrderByOn = True
End Sub
 
G

GIL-PT via AccessMonster.com

Thank you once more.
It worked i changed the name of the field from "left" to "departed" and is
working i didn't change the "time" field because is working fine, but maybe i
should do that too.

Allen said:
You can sort by yes/no fields. True (-1) sorts before False (0).

You can only sort by field names, so presumably you have fields named left,
run id, and time. Time is a reserved word in VBA (for the system time), and
in JET. Left is also the property of controls on your form, as well as a
reserved word in JET. There is therefore a good chance that Access won't
understand what you intend.

Additionally, Access has to save any edits in progress before it can sort
the form for you. You probably want to add this line to the top of each
procedure to explicitly save:
If Me.Dirty Then Me.Dirty = False

Then rename the fields in your tables and queries, and change the Name and
Control Source of the controls on your form. You should then be able to
sort.

For a list of the field names that will give you problems, see:
Problem names and reserved words in Access
at:
http://allenbrowne.com/AppIssueBadWord.html
There's quite a few of them, so you probably want to use the list as a
reference when making fields rather than try to remember them all.
I have a form that shows the result of a query, now i want to be able to
sort
[quoted text clipped - 22 lines]
Forms("RUNS Status").OrderByOn = True
End Sub
 

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