|
|
Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
I posted this previously, and didn't get any answers, so here goes again!
First of all, I have an option frame that filters the listbox based on which option is selected. That works fine. Then I click on the selections in the listbox and put them in a second list, with a cmd button, and using this code snippet (this is not all of the code, but it should be familiar to most of you)-
For intCurrentRow = 0 To ctlSource.ListCount - 1 If ctlSource.Selected(intCurrentRow) Then AWGs = AWGs + CSng(ctlSource.Column(2, intCurrentRow)) WGs = WGs + CSng(ctlSource.Column(5, intCurrentRow)) strItems = strItems & ctlSource.Column(0, intCurrentRow) & ";" & ctlSource.Column(1, intCurrentRow) & ";" & ctlSource.Column(2, intCurrentRow) & ";" & ctlSource.Column(3, intCurrentRow) & ";" & ctlSource.Column(4, intCurrentRow) & ";" & ctlSource.Column(5, intCurrentRow) & ";" ct = ct + 1 End If Next intCurrentRow
This also works fine.
What I want to do, though, is to move from option to option and "remember" the selections from each, so the user would be left with, as an example, one from option A, two from option B, one from Option C. My question is, how? or is it possible? There is also the problem of the user de-selecting items at any point in the process. I would like the user to see a final list in the second listbox that he would then save. I have no idea where to start...... Many thanks to any suggestions.
-- Damon Heron
|
|
Most likely, the trick here will be to identify a string parsing/delimited concept that will allow you to store the option name as well as the selection in such a way that you can easily "find" the desired info when you want to delete/change the info.
There are many ways to do this, but the common theme is to choose a delimiter that separates a pair of data (where a pair is the option name and the selection), and a delimiter that separates the option name and the selection within the pair. Here are a few thoughts:
OptionName1=Selection1;OptionName1=Selection2;OptionName2=Selection1;OptionName1=Selection3;OptionName3=Selection1;OptionName2=Selection2
Then you can use the Split function to separate the pairs into a variant array, using the ; delimiter.
Then you can split a pair using the = delimiter. --
Ken Snell <MS ACCESS MVP>
"Damon Heron" <damon327[ at ]notmail.com> wrote in message news:A5CdnSQR0saq2y3ZnZ2dnUVZ_o6dnZ2d[ at ]comcast.com...
[Quoted Text] >I posted this previously, and didn't get any answers, so here goes again! > > First of all, I have an option frame that filters the listbox based on > which > option is selected. That works fine. Then I click on the selections in > the > listbox and put them in a second list, with a cmd button, and using this > code snippet (this is not all of the code, but it should be familiar to > most > of you)- > > For intCurrentRow = 0 To ctlSource.ListCount - 1 > If ctlSource.Selected(intCurrentRow) Then > AWGs = AWGs + CSng(ctlSource.Column(2, intCurrentRow)) > WGs = WGs + CSng(ctlSource.Column(5, intCurrentRow)) > strItems = strItems & ctlSource.Column(0, intCurrentRow) & ";" > & > ctlSource.Column(1, intCurrentRow) & ";" & ctlSource.Column(2, > intCurrentRow) & ";" & ctlSource.Column(3, intCurrentRow) & ";" & > ctlSource.Column(4, intCurrentRow) & ";" & ctlSource.Column(5, > intCurrentRow) & ";" > ct = ct + 1 > End If > Next intCurrentRow > > This also works fine. > > What I want to do, though, is to move from option to option and "remember" > the selections from each, so the user would be left with, as an example, > one from option A, two from option B, one from Option C. My question is, > how? or is it possible? There is also the problem of the user > de-selecting > items at any point in the process. I would like the user to see a final > list in the second listbox that he would then save. I have no idea where > to > start...... > Many thanks to any suggestions. > > > -- > Damon Heron >
|
|
Damon Heron wrote:
[Quoted Text] >I posted this previously, and didn't get any answers, so here goes again! > >First of all, I have an option frame that filters the listbox based on which >option is selected. That works fine. Then I click on the selections in the >listbox and put them in a second list, with a cmd button, and using this >code snippet (this is not all of the code, but it should be familiar to most >of you)- > > For intCurrentRow = 0 To ctlSource.ListCount - 1 > If ctlSource.Selected(intCurrentRow) Then > AWGs = AWGs + CSng(ctlSource.Column(2, intCurrentRow)) > WGs = WGs + CSng(ctlSource.Column(5, intCurrentRow)) > strItems = strItems & ctlSource.Column(0, intCurrentRow) & ";" & >ctlSource.Column(1, intCurrentRow) & ";" & ctlSource.Column(2, >intCurrentRow) & ";" & ctlSource.Column(3, intCurrentRow) & ";" & >ctlSource.Column(4, intCurrentRow) & ";" & ctlSource.Column(5, >intCurrentRow) & ";" > ct = ct + 1 > End If > Next intCurrentRow > >This also works fine. > >What I want to do, though, is to move from option to option and "remember" >the selections from each, so the user would be left with, as an example, >one from option A, two from option B, one from Option C. My question is, >how? or is it possible? There is also the problem of the user de-selecting >items at any point in the process. I would like the user to see a final >list in the second listbox that he would then save. I have no idea where to >start......
Excuse me, but It kind of looks like you are trying to use code avoid a junction table. From what little I can deduce here, the options and the list box have a many - many relationship and your second list box is trying to play the part of the junction table between them. The whole set of problems outlined in your question will probably be more easily addressed by using three tables.
Try thinking about that and see if it can help clarify your issues.
-- Marsh MVP [MS Access]
|
|
Marshall, My use of options is simply to filter a large container table (>1500 unique items) that contains three types of containers, (barrels, drums, and demijohns) to which the user places liquid in. I also have an "All" option, but by filtering, it reduces the number of items that the user has to scroll thru to get to their selection choice. I don't see how adding more tables would make this any easier for the user to select items and save the selected items.... The second listbox just shows the items selected.
-- Damon Heron
"Marshall Barton" <marshbarton[ at ]wowway.com> wrote in message news:fl72b2hkrqlp2snrnlq90ncg5oq9ol3kbb[ at ]4ax.com...
[Quoted Text] > Damon Heron wrote: > >>I posted this previously, and didn't get any answers, so here goes again! >> >>First of all, I have an option frame that filters the listbox based on >>which >>option is selected. That works fine. Then I click on the selections in >>the >>listbox and put them in a second list, with a cmd button, and using this >>code snippet (this is not all of the code, but it should be familiar to >>most >>of you)- >> >> For intCurrentRow = 0 To ctlSource.ListCount - 1 >> If ctlSource.Selected(intCurrentRow) Then >> AWGs = AWGs + CSng(ctlSource.Column(2, intCurrentRow)) >> WGs = WGs + CSng(ctlSource.Column(5, intCurrentRow)) >> strItems = strItems & ctlSource.Column(0, intCurrentRow) & ";" >> & >>ctlSource.Column(1, intCurrentRow) & ";" & ctlSource.Column(2, >>intCurrentRow) & ";" & ctlSource.Column(3, intCurrentRow) & ";" & >>ctlSource.Column(4, intCurrentRow) & ";" & ctlSource.Column(5, >>intCurrentRow) & ";" >> ct = ct + 1 >> End If >> Next intCurrentRow >> >>This also works fine. >> >>What I want to do, though, is to move from option to option and "remember" >>the selections from each, so the user would be left with, as an example, >>one from option A, two from option B, one from Option C. My question is, >>how? or is it possible? There is also the problem of the user >>de-selecting >>items at any point in the process. I would like the user to see a final >>list in the second listbox that he would then save. I have no idea where >>to >>start...... > > > Excuse me, but It kind of looks like you are trying to use > code avoid a junction table. From what little I can deduce > here, the options and the list box have a many - many > relationship and your second list box is trying to play the > part of the junction table between them. The whole set of > problems outlined in your question will probably be more > easily addressed by using three tables. > > Try thinking about that and see if it can help clarify your > issues. > > -- > Marsh > MVP [MS Access]
|
|
Damon Heron wrote:
[Quoted Text] >Marshall, >My use of options is simply to filter a large container table (>1500 unique >items) that contains three types of containers, (barrels, drums, and >demijohns) to which the user places liquid in. I also have an "All" option, >but by filtering, it reduces the number of items that the user has to scroll >thru to get to their selection choice. I don't see how adding more tables >would make this any easier for the user to select items and save the >selected items.... The second listbox just shows the items selected.
Ahh, I see now. Sorry I wasted your time.
-- Marsh MVP [MS Access]
|
|
"Damon Heron" <damon327[ at ]notmail.com> wrote in news:A5CdnSQR0saq2y3ZnZ2dnUVZ_o6dnZ2d[ at ]comcast.com:
[Quoted Text] > What I want to do, though, is to move from option to option and > "remember" the selections from each, so the user would be left with, > as an example, one from option A, two from option B, one from Option > C. My question is, how? or is it possible?
I would still go with a temporary table. You don't say what you are going to do with the selection once it's made, except that it gets echoed in some other (second) list box. My guess is that you plan to do some kind of processing on the selected records, in which case you need the table to base the processing on.
From there, it's trivial to use the OnChange event of the option group to read an appropriate selection from the temporary table, and reset the first listbox's selection via the .Selected() property. Alternatively, you could just remove the selected items from the first listbox (change the Rowsource to include a NOT IN clause based on the temporary table).
Just a thought...
Tim F
|
|
We use both the table method and the string method.
Both at the same time, and separately.
For example, we have a form that allows you to select different criteria against different parameters for a report.
Each phrase is pushed into a temp table, which is used to display the list of criteria.
The criteria are also parsed into a SQL filter, and also delimitor separated into a string.
The SQL filter is used to filter forms/reports/exports, the temp table is used for display while building the criteria, and the delimited string is used to store the list elements so that they can be saved and re-loaded into the list box (without having to parse the SQL, and there are some non sql options as well).
And yes, we directly use table-based criteria as well as SQL filters, but as it happens, only when the criteria are created by an append query: it's easier to append into a criteria table instead of creating an SQL filter string, but the criteria table join requires that you know in advance the fields you will use in the join.
(david)
"Damon Heron" <damon327[ at ]notmail.com> wrote in message news:A5CdnSQR0saq2y3ZnZ2dnUVZ_o6dnZ2d[ at ]comcast.com...
[Quoted Text] >I posted this previously, and didn't get any answers, so here goes again! > > First of all, I have an option frame that filters the listbox based on > which > option is selected. That works fine. Then I click on the selections in > the > listbox and put them in a second list, with a cmd button, and using this > code snippet (this is not all of the code, but it should be familiar to > most > of you)- > > For intCurrentRow = 0 To ctlSource.ListCount - 1 > If ctlSource.Selected(intCurrentRow) Then > AWGs = AWGs + CSng(ctlSource.Column(2, intCurrentRow)) > WGs = WGs + CSng(ctlSource.Column(5, intCurrentRow)) > strItems = strItems & ctlSource.Column(0, intCurrentRow) & ";" > & > ctlSource.Column(1, intCurrentRow) & ";" & ctlSource.Column(2, > intCurrentRow) & ";" & ctlSource.Column(3, intCurrentRow) & ";" & > ctlSource.Column(4, intCurrentRow) & ";" & ctlSource.Column(5, > intCurrentRow) & ";" > ct = ct + 1 > End If > Next intCurrentRow > > This also works fine. > > What I want to do, though, is to move from option to option and "remember" > the selections from each, so the user would be left with, as an example, > one from option A, two from option B, one from Option C. My question is, > how? or is it possible? There is also the problem of the user > de-selecting > items at any point in the process. I would like the user to see a final > list in the second listbox that he would then save. I have no idea where > to > start...... > Many thanks to any suggestions. > > > -- > Damon Heron >
|
|
|