Re: Combo box to define what column to order by my subform

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Assign the value of the combo to the OrderBy property of the form in your subform, and then turn on its OrderByOn property.

You need to see if the user did select something in the combo.
You also need to add square brackets, since some of your field names contains spaces.

This kind of thing:

Private Sub combosort_AfterUpdate()
With Me.[48_form_Visualiza_Processos subform].Form
If IsNull(Me.combosort) Then
.OrderByOn = False
Else
.OrderBy = "[" & me.combosort.value & "]"
.OrderByOn = True
End If
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Marco" <Marco@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2D2A6AD1-F60A-4D83-BA4C-551F57DB3437@xxxxxxxxxxxxxxxx
Hi. In my form I want to creat a combo box to allow the way that I want to
order my sub form.

the combo will have the options:
- Process no.
- Employee number
- Name
- Date

I want, that my subform will be sort/order brom the opionthat I'll choose on
the combobox.

there's an option on subform that is order by, but I can't reach it from the
code.

I tried:

Me.[48_form_Visualiza_Processos subform].Form.OrderBy me.combosort.value

but it say's "invalid use of property".

How can I solve my problem?

regards,
Marco





.



Relevant Pages

  • Re: Disable sorting on subforms
    ... The OrderBy property accepts strings ... "Barry Gilbert" wrote: ... Private Sub Form_Open ... refer to the name of the subform CONTROL, not the name of the form. ...
    (microsoft.public.access.forms)
  • Re: order of record listing in subforms - unexpected behavior
    ... > Use the Open event of the subform to set its OrderBy property: ... > Private Sub Form_Open ... applied when the subform is opened on its own isn't applied when it is ...
    (microsoft.public.access.forms)
  • Re: Sorting records in a sub-form
    ... Set the OrderBy property of the subform, ... Tips for Access users - http://allenbrowne.com/tips.html ... Command button on the main form. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Repost - Sort Order being lost
    ... You can only sort by a field that exists in the form'sRecordSource. ... If "txtPlacementStageOrder" is the name of a field in the subform's ... you could set the subform's OrderBy property to: ... > changes to this specific subform. ...
    (microsoft.public.access.forms)
  • Re: how can I show query results as a subform !!!
    ... Create the subform and bind it to the query. ... set the OrderBy property of the subform to the ...
    (comp.databases.ms-access)