Command button to change sort order in list

J

Jason

Hi all

Trying to add a button to a column header (The button will be transparent)
The intention, is to have a button for each column, so that when the user
clicks on the button, the sort order in the list will be sorted by the
column. Example... If the column is COUNTRY, then clicking the transparent
button will sort the list by country. If the column is PROPERTY, then the
transparent button will sort the list by property

I am using the following code, but when I click the button the values in the
list fly away into Access Heaven leaving the list empty

Dim strOrderBy As String
Const strcStub = "SELECT QRY_SEARCHENTITY.TXT_PROPERTYID,
QRY_SEARCHENTITY.TXT_PROPERTY, QRY_SEARCHENTITY.TXT_BRAND,
QRY_SEARCHENTITY.txt_COUNTRY, QRY_SEARCHENTITY.TXT_FACILITYID,
QRY_SEARCHENTITY.TXT_BUSINESSUNIT FROM QRY_SEARCHENTITY"
strOrderBy = "ORDER BY QRY_SEARCHENTITY.txt_COUNTRY"
Me.LST_SRCHENTITY.RowSource = strcStub & strOrderBy

Any suggestions on where I am going wrong?

Thanks in advance.
 
B

BruceM

It may be as simple as adding a space before the first word of strOrderBy.
Also, you may need to requery the list box (if that's what it is):
LST_SRCHENTITY.Requery

I can't remember offhand if setting the Row Source takes care of that, or if
you need to requery explicitly.
 
M

Mark Han[MSFT]

Hi Jason,

Thank you for using Microsoft MSDN Managed Newsgroup. My name is Mark Han.
I am glad to work with you on this issue.

From your description, I understand that you would like to use the command
button to change the sort order in the list; however the command buttom
return empty. If I have misunderstood, please let me know.

in order to resolve the issue, I would like to re-produce the issue on my
own machine. if it is convenient to you, please send the sample of the
access databse to me. my email address is
(e-mail address removed)(please remove the online) and then I will
create a FTp workspace for you to upload the information requested. if I
figure the relustion to the issue, we will public it here and send an email
to you.

If there is anything unclear, please do not hesitate to let me know.

Have a nice day!

Best regards,
Mark Han
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: (e-mail address removed).
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or
a Microsoft Support Engineer within 2 business day is acceptable. Please
note that each follow up response may take approximately
2 business days as the support professional working with you may need
further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are
best handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx

============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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