Controls

Bigpapou
07-23-2001, 08:19 AM
Hi,

I have a form in wich you enter a first and a last name. Now if the 2 are not isNull(), there should be only one entry so I search for it and bingo.

Now, if one of them isNull() then there could be more then one entry so I wanna open another form with a scrollingdown list box()(sorry but... dunno how to call those in english) in wich the user will find all the choices associated with the first or last name he entered.

As an example:let's say you're searching for Bob Dylan. You enter Bob in the "firstName" box and click the GO button... then the other form pop's up and ask you to choose from the list:

Bob Clark
Bob Dylan
Bob Binette...

How to do that???
I've read the "AddItem(Text, Index)" method but I don't quite understand.
!!!Any help would be appreciated!!!

Thinker
07-23-2001, 08:24 AM
You only need the index parameter if you are trying to sort them into the listbox in some special order. I guess you are going to issue a query to find all matching then loop through the resultset doing the additem(resultsetvalue). I hope this is clear.

KesleyK
07-23-2001, 08:48 AM
Like Thinker not quite sure what you're asking, but this should retrieve your sorted information into a rs:

Set rs = db.OpenRecordset("SELECT * FROM [TableName] WHERE [FieldName] = '" & Name & "'")
rs.Sort = "[FieldName]"
Set rs = rs.OpenRecordset

______
Cheers!

Bigpapou
07-23-2001, 08:52 AM
I'll be clearer:

1- I have a list of name that I've selected...
2- I want to add them into a list box so the user can select one.

This is why I need the additem function

Thinker
07-23-2001, 09:04 AM
Are you working in Access? If so, I don't believe there is an additem function. I think there is another way by stuffing all the values into the Rowsource.

KesleyK
07-23-2001, 09:27 AM
In Access VBA the ListBox data will need to come from a table or query. As far as I can see it can't be added programmatically.

______
Cheers!

Thinker
07-23-2001, 09:38 AM
Here is how you add it programmatically.
<pre>
List0.RowSourceType = "Value List"
List0.RowSource = "'Value1';'Value2';'Value3'"
</pre>

KesleyK
07-23-2001, 09:44 AM
*SHAKES HEAD* Now, if a source can be defined, why not at RunTime? Thanks, Thinker.

______
Cheers!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum