Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Welcome to the skill header Forums. You can ask questions, get help, or help other members out. Join our Forum for free.
I think I have it figured out and it works…..added an On Exit sub routine that resets the orderby, icon and request the form.
DoCmd.SetOrderBy "AccCode ASC"
Me.CmdAccCode.Picture = "C:\Users\Owner\Desktop\sort a-z.png"
me.requery
this works well, although I am having trouble with the SName cmd button. Give it a try and see if you can improve this even more.
Fred
All,
Attached is a short video showing the process in action. I tried to emulate Excel sort mode as best as I could. Comments
My bad, I failed to set the On Exit to reorder AccCode. Here is my final version.
Here is the code I used. I used the same code for each button, making sure I edited each one appropriately. As you can see it works quite well. Enjoy! I did make three (3) custom Icons; Access-Sort-Norm.png, Access-Sort-Asc.png, and Access-Sort-Desc.png to make this work right. If you would like, I can share those images for you to use. I do assign the Access-Sort-Norm.png as the embedded image in the property sheet. IMPORTANT: ensure your path to your images are yours, not mine. You can have them locally or on a server depending on how you deploy them. This was fun and is my very first custom function.
Option Compare Database Option Explicit 'This code is brought to you by Fred Stetson, of Stetson Management Solutions 'You may use this code as long as you keep this statement intact. 'This code is for sorting using a Command Button, and images to reflect sort order. 'The intent is to emulate MS Excel sort function in column headings Private Sub CmdAccCode_Click() If Me.OrderBy = "AccCode" Then Me.OrderBy = "AccCode Desc" Me.CmdAccCode.Picture = "C:\Users\Owner\Desktop\Access-Sort-Desc.png" Else Me.OrderBy = "AccCode" Me.CmdAccCode.Picture = "C:\Users\Owner\Desktop\Access-Sort-Asc.png" End If End Sub Private Sub CmdAccCode_Exit(Cancel As Integer) Me.OrderBy = "AccCode" Me.CmdAccCode.Picture = "C:\Users\Owner\Desktop\Access-Sort-Norm.png" Me.Requery End Sub