Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box Question

Status
Not open for further replies.

sgfromny

Technical User
Jan 17, 2003
120
US
I have a list box that is populated by a query but will always have just one value, Is there a way to Select without clicking it, using VBA?
 
when you say select it...

do you mean set it as focus? or automatically set that as first control on a form? or find out it's value?

plus, if it's always going to be just 1 value, then why not use a text box instead?
 
The list box has 4 columns, when its populated by the query, it just appears in the box. Its not selected, so accessing the value through "me.list.column (1)" reports nothing until it has been selected. I dont know how to have a text box report back results from a query, can it do that?

Please advise
 
sgfromny,
using the selected property of the list box can authomatically shif focus to a desired row. Modifying the code below to suit your need may work.

Private Sub Command2_Click()
On Error GoTo Err_Exit
'i is a global Variable
List0.Selected(i) = -1
If i = 0 Then
i = 1
Else
i = 0
End If

Err_Exit:

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top