selecting values of a list box from an input text string

G

Guest

I'm not sure if I'm approaching the overall situation correctly but I need a
resolution to this.

I have an input form that users utilize and select from values of a list
box. This form has a command button on it that runs code to take the values
of the list box and formulates it into a text string based on what the user
selected to save to a table (such as "batch, name, model"). This part works
without any issues.

Now what I am working on is a different form that allows the user to modify
these saved values still utilizing a text box. What I want to do is to be
able to read that string back into a list box and display it for the users to
edit. The listbox will be based off a table/query so each value that is in
the string (separated by a space and comma) will be already be in the list
box.

Is there a way that I can read in this text string and highlight the values
in the listbox where the users can select/unselect the values? When they are
ready to save it, I will re-run the original commands to parse the list box
back to the text string for the value to be stored on a table but presenting
the previously stored selected values is my issues.
 
P

pietlinden

I'm not sure if I'm approaching the overall situation correctly but I need a
resolution to this.

I have an input form that users utilize and select from values of a list
box. This form has a command button on it that runs code to take the values
of the list box and formulates it into a text string based on what the user
selected to save to a table (such as "batch, name, model"). This part works
without any issues.

Now what I am working on is a different form that allows the user to modify
these saved values still utilizing a text box. What I want to do is to be
able to read that string back into a list box and display it for the users to
edit. The listbox will be based off a table/query so each value that is in
the string (separated by a space and comma) will be already be in the list
box.

Is there a way that I can read in this text string and highlight the values
in the listbox where the users can select/unselect the values? When they are
ready to save it, I will re-run the original commands to parse the list box
back to the text string for the value to be stored on a table but presenting
the previously stored selected values is my issues.

OUCH. That's a painful alternative to a subform if I ever saw one. I
guess you could use SPLIT and loop through the resulting array, but it
sounds like so much unnecessary hassle. Validation really isn't
possible... I would vote against it. I love to code, but this sounds
like a huge hassle. Might be a good intellectual challenge, but I
think it's a poor solution to the problem. Hope I didn't offend you.
Definitely did not mean to, but I think your approach is going to lead
you into difficulties.
 
G

Guest

Well, I'm not offended as I'm sure I'm taking a complicated route. But it
was what I thought of when I had a requirement to have the data from the list
box stored in the table and the capability of that data to be pulled up on a
report. The tech I was helping on this did a previous post and he said he
was told it couldn't be done and he was going to make a ton of combo boxes
and have the user entering the data select each value (10 to 20) from
different combo boxes and have the 10 to 20 fields on a table.

So ultimately, list boxes for entry/editing is what I need to work with and
the selections need to be able to be pulled up on report fields as well as
other forms. The data needs to be stored in the table and easy to read/work
with. The saving to the table was easy but then going back with the ability
to modify is killing me. I'm definitely open to suggestions incase I'm
overlooking something easy and making it harder then it needs to be.
 
G

Guest

I do want to say you did hit on what I was looking for. I did manage to get
it to work fine with the split command to make the array to populate the list
box.

This ended up working:

Dim indextext as string
Dim indexname as variant

For Each indexname In Split(indextext, ", ")
For value = 0 to Me!List10.Listcount
If Me!List10.ItemData(value) = indexname Then
Me!List10.Selected(value) = True
End If
Next value
Next indexname

I do agree it may be overkill but for now, at least I have something that
works. Thanks for your help and I still may be looking for that other method.
 

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

Top