473,386 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

capture several items selected from combo box into an array for later save operation

22
VB6 Question

Need to know how to capture several item selections from a single (as opposed to a multi selection) combo box drop down, into an array for later saving into a table on pressing the save button.
I need a coded example please.
Also, under which event (OnFocus, AfterUpdate....) would I put this.

Thanks
Jun 19 '10 #1

✓ answered by p4willi

Thanks for the tip. It worked.

How do I reference this array, that I have built in a sub form from the save button on the main form?

10 2476
vb5prgrmr
305 Expert 100+
Using VBA? Try the OnClick event or if vb6.0, the click event...



Good Luck
Jun 20 '10 #2
p4willi
22
Thanks - but please show me with coded example how to store the captured items into an array.
For example I choose the first item from the drop down and then click a check box, then come back to choosing another item from the same drop down and click another check box.
All these chosen items and check boxes are to be stored temporarily - in an array - and finally when I press the save button it should write into a table.
Jun 20 '10 #3
vb5prgrmr
305 Expert 100+
A lot of sites and people frown upon those asking for code without trying for themselves to solve the problem...

What is even more frowned upon by individuals is recieving a pm asking for code...

So, I'll tell you what I will do. I'll give you some more hints on how to solve this...

Use dynamic arrays for the strings and for the check boxes.
Use ReDim Preserve to redimension your arrays to a larger size to hold the information.
Use a variable or two to keep track of both of your arrays dimensions.
The arrays and variables are to be declared in the general section of the form while the redim should be used in the event itself.



Good Luck
Jun 21 '10 #4
p4willi
22
Thanks for the tip. It worked.

How do I reference this array, that I have built in a sub form from the save button on the main form?
Jun 21 '10 #5
vb5prgrmr
305 Expert 100+
Declare the array as public in the second form and when you/the user is done with the second form, don't unload it, hide it...

in form1
Expand|Select|Wrap|Line Numbers
  1. Form2.Show vbModal, Me
  2. 'rest of processing code here if needed
  3.  
in form2
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command_Close()
  2. Me.Hide
  3. End Sub
  4.  
Then back in form1 when you click on save
Expand|Select|Wrap|Line Numbers
  1. Dim ForLoopCounter As Integer
  2. For ForLoopCounter = LBound(Form2.PublicArray) To UBound(Form2.PublicArray)
  3.   '...
  4. Next ForLoopCounter
  5.  


Good Luck
Jun 22 '10 #6
p4willi
22
@vb5prgrmr
Thanks again - will give this a shot and let you know.
Jun 23 '10 #7
p4willi
22
@p4willi
Hi vb5prgrmr,
What is the best way to capture several selections from a combo box of selections and for each selection two related checks (ticks).
How would I store all these selections until I press the save button that inserts into the table.
If there are there examples of such please point me to them.

Thank you much
Jun 24 '10 #8
vb5prgrmr
305 Expert 100+
Wow, I really thought I had answered this already...

Lets see, what have I written so far...

>Using VBA? Try the OnClick event or if vb6.0, the click event...

>Use dynamic arrays for the strings and for the check boxes.
>Use ReDim Preserve to redimension your arrays to a larger size to hold the information.
>Use a variable or two to keep track of both of your arrays dimensions.
>The arrays and variables are to be declared in the general section of the form while the redim should be used in the event itself.


Okay, yeah! I have given you all the hints you need to start building your code. So where is it? I mean, where is your code? What have you tried? Do you even know what an array is? Or a dynamic array? Do you know what a string is? And no, it is not something rolled up into a ball or on a spool that cats love to play with!

Please, try out some code. Look up dynamic arrays. Give it a go!


Good Luck
Jun 24 '10 #9
p4willi
22
@vb5prgrmr
Ok..Ok, i like the sarcasm..
I've got the arrays to work nicely. Every time the user selects from the combo and chooses check boxes, this set of selections is now stored into the array on the change event.

But how do I insert into the table only the last choice the user made (assuming he has made up his mind once and for all) thereby storing a unique choice?
Jun 25 '10 #10
vb5prgrmr
305 Expert 100+
Use the UBound Function (if using dynamic arrays) to find out what the largest dimension is...



Good Luck
Jun 25 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Kees S. | last post by:
I have a for-loop to add items to an array, but when i use a for loop to print these items, iI only get the last item of the array. This is a simplified example of what i do, what is wrong with it:...
1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
2
by: John | last post by:
Hi Is there a way to get the count of selected items in a list? Thanks Regards
4
by: Rob Meade | last post by:
Hi all, Ok - I appreciated I could probably just do this : For Each item IN array intCount = intCount + 1 Next
2
by: Tom Bray | last post by:
Ok I am baffled I can not figure out this problem. I am getting the following error: Portal Error - A DropDownList cannot have multiple items selected. Error information Name Value Message...
1
by: dadevil | last post by:
Hi guys, this is my first post around here, and here it goes I need to create an array to store info about a number "n" of persons, so i create this structure ( each person have one name and one...
3
by: student1 | last post by:
how to capture a listbox selected value in to variable.im able to capture radibox value and check box value but for dropdownbox im not able to capture.plz help me
2
by: =?Utf-8?B?S3Jpc2huYQ==?= | last post by:
Hi, I am devloping one web application using .net framework 2.0.One page has 7 dropdown list control.When i update the values first bind the values to the drop down llist then selected text...
3
by: jschmidt | last post by:
Hello Everyone, I am trying to keep a running total of the number of items selected in a multiselect list box. I want to do this in vb code and update the number dynamically everytime they select...
11
Hiren Joshi
by: Hiren Joshi | last post by:
Hello All Experts, I am a Moderate VB Programmer. I am developing one Application at the moment with VB 6.0 and MS Access. Operating System is Win XP. Its a Multi User application. What I want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.