array

  • Thread starter Thread starter Ezekiël
  • Start date Start date
E

Ezekiël

Hi,

Can anyone help me with creating a combobox from an array?
I have some fields in my table with names like a1_1, a1_2, a1_3, etc. Their
values in the record can be like 1, 2, 3.

How can i use it in a combobox? I think i need to merge the fields with a
seperator, so it can be seen as a array and set the values in a combobox
like manner.

I don't know how to do it, so if someone would help me understand it how to
do it.
 
The problem you have is that you don't send field data to a combo box. You
send a "field", or what is refereed to is a column.

So, listbox, or a combo box needs to you give it what field to display, and
you can also have some criteria for that combo box.

select City from tblCites where Country = 'Canada'

The above sql thus could fill the combo box with all cities from my country,
assuming we have nice database off all Countries. Note have we have a table
with the data, we do NOT have a database with:

City_USA City_Canada City_Germany


Note how the above is a real mess from a data design point of view. You
should NEVER have multiple fields in a record to store repeating data. So,
for example, the above record that holds cites as above would be converted
to:

City Country
Edmonton Canada
New York USA
Calgary Canada


Further, for making reports and filling combo boxes, you can see how ease
the last example is to work with. Further, if I have to add a new city to
the database, then I NEVER have to add a new field. Adding fields is really
hard, since all forms, reports, combo boxes etc will have to re-built or
modified if you add a new field. So, your designs should be such that new
data should NOT take a new field. This whole process of data modeling is
called normalization.

In your case you have:

a1_1, a1_2, a1_3, etc.

Those values should be broken out to another table, and then *RELATED* back
to the current record. That way, you can have as many, or as few values for
the one record you want (this is called a one to many relationship).

It is also not clear if you need to fill the combo box with values a1_1,
a1_2, a1_3, etc from ONE record, or all records together? Doing this is a
bit messy. You don't mention how many values you have in that record.
(a1_?).

If the combo is to be filled with data form just ONE record, then you can
write a loop to build a source for the combo box (but, what are you gong to
do with the combo box then?).
 
Hi,

Can anyone help me with creating a combobox from an array?
I have some fields in my table with names like a1_1, a1_2, a1_3, etc. Their
values in the record can be like 1, 2, 3.

How can i use it in a combobox? I think i need to merge the fields with a
seperator, so it can be seen as a array and set the values in a combobox
like manner.

I don't know how to do it, so if someone would help me understand it how to
do it.

I'm not sure what you're trying to accomplish. Do you want to base one
combo box on the three fields? Do you want to use a combo box to pick
al_2 or al_1?

The basic problem is that you're violating normalization with the
design of your table: having a one to many relationship embedded in
each record of a table IS SIMPLY BAD DESIGN and will make it difficult
to use with a combo. Any chance you could restructure this table so
that you don't have repeating fields in the table, but rather have two
tables in a one-to-many relationship?
 
Back
Top