Reputation: 1567
I have a form in Access like this: When I click on "Order" button, I want to order the "client" table (shown in the bottom) order by "firstname". How I can do? Can I use macro or I must use VBA code? So far I have only used macro, I never used VBA.
Upvotes: 0
Views: 2381
Reputation: 679
You can use VBA in the OnClick Event.
Click on your button while in Design View. Then go over to the properties and go into the Event tab, click in the text box for the On Click Event. Youll see a button with 3 periods appear. Click that and select the Code Builder.
It will bring up a Sub like the below. Just put that line of code in there and your done.
Private Sub OrderButton_Click()
DoCmd.SetOrderBy "[FieldYouWantToSortBy]" DESC, ""
End Sub
Upvotes: 1