OrderBy OrderByOn - Continous Form Sorting

W

WebDude

hello again :)


I have a continuous form, based on a table/query. I created a button on that
form;

me.form.orderby = "[LastName]"
me.form.orderbyon = true

and another button with;

me.form.orderby = "[FirstName]"
me.form.orderbyon = true

and they both work fine!


However, i have a text field called "Age" placed on the same continous form,
which takes the value in the "BirthDate" field of the table and calculates
the age. So, i added a button on the same form and put;

me.form.orderby = "[Age]"
me.form.orderbyon = true

but when i run the continuous form, it asks for the value of "age" when i
ran the form. So i changed it to;

me.form.orderby = "Age"
me.form.orderbyon = true

but again it prompts me with a dialogue asking for the value of "Age".
so i tried several different combinations;

me.form.orderby = "me.[Age]"
me.form.orderby = me.Age
me.form.orderby = me.form.Age
...etc, etc etc

None of them sorted the records by the "Age" field i placed on the
continuous form.


Coincidentally,the [Birthdate] table field that is also on the same form has
a format of mmmm dd", "yyyy - but id like to sort the records based on
the DAY value of the birthdate ONLY - ignoring the month, and year values.
So i thought i was smart in scipting this to a button for sorting the records;

Me.Form.OrderBy = "Format([Birthdate], 'dd')"
Me.Form.OrderbyOn = true
me.form.refresh

but um. that didnt work either. so then i created a field on the same form,
named it BirthDayText, with the control source "=Format([Birthdate],"dd")"
and when i run the form, the correct number appears in the field, but i have
the same problems sorting it.

Me.Form.OrderBy = "[BirthDayText]"
me.Form.Orderbyon = true

wont work.

Oh! i even added... me.form.refresh and me.form.requery at the end of every
sort , but still no go.



Any comments or suggestions?
Cheers,
Jeff
 
W

Wolfgang Kais

Cheers WebDude.

WebDude said:
[...]
I have a text field called "Age" placed on the same continous form,
which takes the value in the "BirthDate" field of the table and
calculates the age. So, i added a button on the same form and put;

me.form.orderby = "[Age]"
me.form.orderbyon = true

but when i run the continuous form, it asks for the value of "age"
when i ran the form.
[...]

Modify the query the form is based on to contain a field "Age"
that calculates the age and use your code:
Me.OrderBy = "Age"
Me.OrderByOn = True
Coincidentally,the [Birthdate] table field that is also on the same form
has a format of mmmm dd", "yyyy - but id like to sort the records
based on the DAY value of the birthdate ONLY - ignoring the month,
and year values.

Add a calculated field to the query: Day: Day([Birthdate])
and us similar code to order by Day.
 
W

WebDude

Wolfgang! Hello :)

Thank you very much for your reply!

In otherwords,there is no way to sort/order a continous form based on a
TextBox?
Rather, the Orderyby only works on Fields that are from the table/query
that make up the forms RecordSource?

I ask this because, the queries which makeup this forms recordsource are
also the recordsource of other forms - and those other forms do not use or
need the AGE. So, i thought placing a TextBox which calculated the AGE on
just this form (which needs it) would spare the other forms burden of
handling the extra data.

Regardless, i will impliment your original suggestions - unless you come up
with anything else :)

Cheers :)
Jeff

(aka: WebDude)



one more smiley should do it
:)
 

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

Similar Threads

Optionbutton Not working 3
Dynamic Naming of Form Button 3
Orderby doesnt go away 4
Limits of IIF? 4
Is this possible? 0
age groups 8
Calculating age with If statement 2
DLookup in Continuous form 0

Top