Need to simulate listbox click in VBA

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

Guest

I have a listbox which lists a set of sql queries. In some cases I need to programatically do what would happen if a user clicked on a given row
When this happens I load the listbox with just the row I am simulating and I call the 'onclick' routine. However, I get 'type mismatch' error on this statement

frmX!lblTickets.Caption = Me!LB.Column(1

Do I have to set some property for the row to indicate it has been 'clicked'?
 
David said:
I have a listbox which lists a set of sql queries. In some cases I
need to programatically do what would happen if a user clicked on a
given row.
When this happens I load the listbox with just the row I am
simulating and I call the 'onclick' routine. However, I get 'type
mismatch' error on this statement:

frmX!lblTickets.Caption = Me!LB.Column(1)

Do I have to set some property for the row to indicate it has been
'clicked'?

If the list box is single-select, not multiselect, then set its Value
property to the ItemData property of the row you want to select; e.g.,

' Select first row in combo box.
With Me.LB
.Value = .ItemData(Abs(.CoumnHeads))
End With

If the list box is multiselect, then set the .Selected property of the
desired row:

With Me.LB
.Selected(Abs(.CoumnHeads)) = True
End With
 
Back
Top