Giacomo Brunetta
Giacomo Brunetta

Reputation: 1567

Sorting element of a form in Microsoft Access

I have a form in Access like this: enter image description here 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

Answers (2)

Pants
Pants

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

Giacomo Brunetta
Giacomo Brunetta

Reputation: 1567

Done. I used a macro with "SetOrderBy".

Upvotes: 0

Related Questions