Combo box to define what column to order by my subform

M

Marco

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
 
A

Allen Browne

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
 
R

Rod Plastow

Hi Marco,

I think, offhand, without testing, that you are missing an assignment
operator or equals sign.

Shouldn't the syntax be ... OrderBy = ....

Rod
 
M

Marco

very, very, very good.

outstanding.

thanks my griend.




Allen Browne said:
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

Reply to group, rather than allenbrowne at mvps dot org.

Marco said:
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
 

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