Address unbound listbox

H

Harmannus

Hallo,

How do i address an unbound listbox (=CPList) in the below "OrderBy"
statement? Tried various combinations but can't get it to work.

Forms![frmCP].CPList.OrderBy = "qselCPList.Lastname"
Me.CPList.Requery

I get a error message if i use the above.

CP stands for Contactperson.

Thanx for any tips.


Regards,

Harmannus

---- Full code ---

Me.Requery
Select Case Sorteren.Value
Case "1"
Forms![frmCP].OrderBy = "tblCP.Lastname"
Forms![frmCP].CPList.OrderBy = "qselCPList.Lastname"
Me.CPList.Requery
Case "2"
Forms![frmCP].OrderBy = "tblCP.Firstname"
Case "3"
Forms![frmCP].OrderBy = "tblCP.OrganizationID"
End Select
 
C

Chuck Minarik

CPList is a control on the form, not a property.
Therefore, try preceeding it with an exclamation point
rather than a period, like so:

Forms![frmCP]![CPList].OrderBy

Chuck
 
M

Marshall Barton

Harmannus said:
How do i address an unbound listbox (=CPList) in the below "OrderBy"
statement? Tried various combinations but can't get it to work.

Forms![frmCP].CPList.OrderBy = "qselCPList.Lastname"
Me.CPList.Requery

I get a error message if i use the above.


List boxes do not have an OrderBy property. You should set
the box's RowSource to a query that sorts the records.
 

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

Unbound listbox 0
Unbound list box and search 0
Sort unbound list box 3
Requery main form from subform? 2
Unbound listbox 4
Disable scrollwheel? 3
Unbound listbox 2
ListBox Questions 3

Top