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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ItemSelected Property

Status
Not open for further replies.

Icecream7

Programmer
Apr 19, 2006
35
US
In one of my forms I have about 20 or so different list boxes that contain different information for the catagory they are under. What I would like to happen is for the selected items to be stored in a table that would be used later to create a print out with the selected items. Can any one suggest an easy way of doing this? LOL like programming is easy. Also would it be better to use a write method and have it store the choices in a .txt file?

Thanks
 
How about creating a table, with twenty or so different fields, and bind the list boxes to it?

I'm probably missing something here,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Only thing is the list boxes are set to where you can choose more than one thing in them. I thought of that also and have a table created already but I'm brain dead on how to specify which field the selected goes into.
 
How are ya Icecream7 . . .

Its a little more work but you could build [blue]delimited strings[/blue] to store in the proper fields!

Your thoughts? . . .

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceman1

Not doing to bad except for my confidence level. This can be so frustrating sometimes....oh well!!

If I would do a delimited string for the fields would I need to have one for each item in the list box? I was also wondering about maybe exporting it to a excel spread sheet because the final form will have the dollar values for each kit and need to do calculations. I hate math so if I can find an easy way to do it.....

Is this what you mean by delimited string?
=[FirstName] & " " & [LastName]
 
That would be space delimited, comma delimited (with quotes as a text qualifier are more common).

Now that I know your feelings about math I hesitate to bring this up but you could use bit masks for your values in the the list boxes. This will allow you store multiple values in the same field, for example a two column List Box would have values like:[tt][ul][li]0 Nothing Selected[/li][li]1 First Item[/li]
[li]2 Second Item[/li]
[li]4 Third Item[/li]
[li]8 Fourth item[/li]
[li]16 Fifth Item[/li]
[li]32 Sixth Item[/li][/ul][/tt]

This way any selection, or combination of selections will have a unique value (by adding the individual values) which you can pull out using an [tt]AND[/tt], here is an example.
Code:
  For intRow = 1 To ListBox.ListCount
    If 2 ^ (intRow - 1) And [Field].Value Then
      ListBox.Selected(intRow) = True
    Else
      ListBox.Selected(intRow) = False
    End If
  Next intRow

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Icecream7 . . .

[blue]CautionMP's[/blue] bit mask method would work only remember your talking a print out here, not reselecting in the listbox.

Considering you will be delimiting (lets say semicolon delimited) the actual values for printout your set.

Example listbox1:
[tt]ID Name
** ****
23 Benny
24 Bob
25 Sue
56 John[/tt]

The table field for listbox1 would be:
Benny;Bob;Sue;John

To seperate the names out you turn to the [blue]Split[/blue] function:
Code:
[blue]   Dim Ary, x As Integer
   
   Ary = [purple]Split[/purple](MeFieldName, ";")
   
   For x = LBound(Ary) To UBound(Ary)
      Debug.Print Ary(x)
   Next[/blue]

Calvin.gif
See Ya! . . . . . .
 
So would I need a table for each listbox that would also store the customer number and in the long run combine all those options? I do have a sub form that has the customer information on the top, this is brought in from a customer query. From what I was told they do have some bids that end up with 5 to 10 kits chosen for the one customer. The columns in the list box are 1st kit*** 2nd what that kit is (eg Kit123 Tonka). That list box would have a name Trucks.
Some of these have quite a few kits listed.

If I would do the array would I make it a public and then in the private do a IF Else statement that would call the array?
 
Icecream7 said:
[blue]So would I need a table for each listbox that would also store the customer number . . .[/blue]
No! . . . the table structure would be as follows:

TableName = YourChoice!
PrimaryKeyName = Approriate Name/Type
CustNo = Approriate Name/Type
FieldName1 = ListBoxName1/Type
FieldNameN = ListBoxNameN/Type

Ech field relating to a listbox would have the delimited value of all selections made for that listbox! . . . Get it!

Your thoughts? . . .

Calvin.gif
See Ya! . . . . . .
 
This may just work....I could use the CustNumber as the primary key for the table since it's realted to the other tables. Any other suggestions are so welcome. I have done programming for almost a year and that was when I was in school for it. We covered Access but just the basics, I took VB also but I can't seem to get over the hump of relating the two.

It's the end of the day and I don't make sense to myself so I hope you can understand what I just said...LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top