VB

F

Fie

hey...


Iv found some code that allowes user to select from a option group then

results appear in list box. But am unsure what this code should be
attached to/where to put it..
Also i understand most of it but I am confused as to what


[By Search Type].RowSource = "SELECT................"


does this ref the query you are working from looks like SQL to me??
HELP


code is:


Private Sub Type_of_Search_AfterUpdate()


If [Type of Search].Value = 1 Then
[By Search Type] .RowSource = ""
[Search Text].Caption = "Select the School Name to Search For"
[By Search Type].ColumnCount = 3
[By Search Type].ColumnWidth = "2 in;1 in;0 in"
[By Search Type].BoundColumn = 3
[By Search Type].RowSource = "SELECT................"
ElseIf [Type of Search].Value = 2 Then
[By Search Type].RowSource = ""
[Search Text].Caption = "Select the Cost Centre to Search For"
[By Search Type].ColumnCount = 2
[By Search Type].ColumnWidth = "1 in;2 in"
[By Search Type].BoundColumn = 1
[By Search Type].RowSource = "SELECT............"
End If


End Sub


Any1 got any idea????
 
M

Michel Walsh

Hi,


To 'select' a row in a list box has nothing to do with SQL in itself. It is
just plain VB/VBA code, once the list is filled with its data.

To mark a row as selected, use the property Selected(i)=true.
To find the row, you can iterate on ItemData, from 0 to ListCount-1.


Have a form, a listbox list0, multiselect=2 (extended), with values "a",
"b", ... "k" filling the list.
Have a command button, command2.

The following code will "select" the line "c" in the listbox:

===========================
Option Compare Database
Option Explicit

Private Sub Command2_Click()

Dim i As Long

For i = 0 To Me.List0.ListCount - 1
If "c" = Me.List0.ItemData(i) Then
Me.List0.Selected(i) = True
End If
Next i
End Sub
==========================



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VB 3
ComboBox List Limitation 65526 2
List box 3
Combo is null 4
combo box doesn't filter record in a form 1
Search Form and PickList Form 4
Cascading Comboxes 2
Using DoCmd.FindRecord 3

Top