Sorting data in form

hardrock

Registered User.
Local time
Today, 20:13
Joined
Apr 5, 2007
Messages
166
Hi all, i'm using the following two lines in VBA to return filtered results on my form.
What do i need to add to this to have the flexible in sorting the data asending or decending by say any column heading i.e "Parts" or "Date"
I'm not using a query in this particular case. Thanks

Me.Filter = strWhere
Me.FilterOn = True
 
hi,

If you want to use the form's filtering, you need to include these lines.

Me.OrderBy = "Parts DESC"
Me.OrderByOn = True

Hi all, i'm using the following two lines in VBA to return filtered results on my form.
What do i need to add to this to have the flexible in sorting the data asending or decending by say any column heading i.e "Parts" or "Date"
I'm not using a query in this particular case. Thanks

Me.Filter = strWhere
Me.FilterOn = True
 
re:

Can the orderby command sort the records ascending or decending? if so, hows it done? thanks
 
Hi,

Look at the code again.

"Parts" is the field you orderby
"DESC" is the order by descending

If you want to order by ascending just use "Parts" without "DESC"

Got it?

PS. "Date" is a reserved name in Access, avoid using it. If possible rename it.

Can the orderby command sort the records ascending or decending? if so, hows it done? thanks
 
Last edited:
re:

yes i understand what you say, but it doesn't seem to work with the code im using below.. i've tried commenting out the filter, still no joy. Below, i'm trying to order the filter results by Input dates. Thanks


lngLen = Len(strWhere) - 5
If lngLen <= 0 Then 'Nah: there was nothing in the string.
MsgBox "No criteria", vbInformation, "Nothing to do."
Else 'Yep: there is something there, so remove the " AND " at the end.
strWhere = Left$(strWhere, lngLen)

'Apply the string as the form's Filter.
Me.Filter = strWhere
Me.FilterOn = True

'Added these lines, but it dont work

Me.OrderBy = "([Input Date]) DESC"
Me.OrderByOn = True
 

Users who are viewing this thread

Back
Top Bottom