Assigning an On Click event to a label

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to assign an On Click event to a label on a subform which will
allow you to sort the records displayed? For example, the label for the date
field on a subform: click on it the first time and records are sorted
ascending. Click on it a second time, and records sort in descending.
 
Desiree,
Replace your label with a text control. It has an OnClick event to hang the sortiung
code on.
Ex. a text control with a ControlSource of....
= "This looks like label text"
 
Labels that are not the child of a text box or other control will have an On
Click event. You can use code behind this event like:

Dim strSQL as String
strSQL = "SELECT...FROM...ORDER BY OrderDate Desc;"
Me.RecordSource = strSQL

I suppose you could search the Record Source for Desc at the end to toggle
the Ascending and Descending order.
 
Good point Duane... I "thought" labels had a Click event, (I've even used it before) but
when I jumped into my test database this morning to check it out, I couldn't find that
event on my labels. As you say, my labels were associated with text controls.
Live and learn...
Al Campagna
 
Back
Top