Saving option selected in Unbound combo boxes?

B

BadJooJooJen

I have 4 unbound combo boxes on a form. (I created them this way before I
realized that unbound controls don't save data in records/tables.) I have
the combo boxes set up and coded how I want but how can I get the form to
save the options I select in the combo boxes? When the value in the combo
boxes changes, it changes in all the saved records.

Thanks!

Jen
 
T

Tom Wickerath

Hi Jen,

Open your form in design view. Click on View > Properties (or press F4 if
using Access 2002 or 2003) to view the properties dialog, if it is not
already displayed. Click on the first combo box. You should see the name of
this control displayed in the blue title bar of the properties display.
Select the Data tab in the properties display. Bind each combo box using the
Control Source property. Click into the Control Source. Click the dropdown
arrow. Select the appropriate field. Your combo box is now considered a bound
control.

Tom
_________________________________________

:

I have 4 unbound combo boxes on a form. (I created them this way before I
realized that unbound controls don't save data in records/tables.) I have
the combo boxes set up and coded how I want but how can I get the form to
save the options I select in the combo boxes? When the value in the combo
boxes changes, it changes in all the saved records.

Thanks!

Jen
 
B

BadJooJooJen

Yes, this is what I need. Break it down for me. The combo boxes all had
their own tables. The bound fields on the form were in the same table, and
the form is bound to this table. So I added fields into this table for my
combo boxes and changed the Control Source of each combo box to the
corresponding field in the table. Now the data from the combo boxes is
saved, but not the values I want. Each combo box table has an Autonumber
field that I use to establish the relationships as the first column. This
autonumber value is what is being saved. How can I set it up so the value
that shows in the drop down of the combo box is what is saved?

Thanks!
 
T

Tom Wickerath

Hi Jen,
This autonumber value is what is being saved.
In other words, the primary key from each lookup table is now being saved in
each of the new fields that you created as foreign keys? If so, then this is
exactly how it should be set up. You really don't want to store the
corresponding text associated with the primary key value (ie. the "looked-up"
value) in the table that has your four new fields (child table). Also, in
order to properly save the autonumber values in the child table, each of the
new fields should be a number with long integer selected in the lower window
of table design, since an autonumber is a long integer.

A combo box will display only one value when it is not the active control
(ie. not expanded). Is your combo box currently displaying the primary key
value? If so, the fix is quite simple: Use the properties dialog as described
before in form design view. If the primary key is the first column in the Row
Source (table or query), then you want the Bound Column property set to 1
(first column) on the Data tab. On the Format tab, you want the Column Count
property to match the number of columns in the row source. The fifth property
in the list on the Format tab is column widths. If the value that you want
displayed in the combo box when it is not the active control is in the second
column of the row source, and the primary key value is in the first column,
then set the column widths to: 0";1.5" (or whatever is appropriate). Only
the first non-zero width column will be visible until you click on the combo
box to make it the active control.

Also, is the row source for you combo boxes a table or a query? It sounds
like you had a table set as the row source. In general, you want either a
saved query or a SQL (Structured Query Language) statement as the row source.
(You can spot a SQL statement pretty; it would start with the SELECT
keyword). Using a SQL statement or saved query allows you to retrieve only
the required fields (primary key + lookup description) instead of pulling all
fields from a table. That means that the combo box will load faster when the
form is opened. While you likely won't notice this with a single-user
application, it can add significant delay if your database is split into a
front-end (FE) and back-end (BE) databases, and the BE is located on a file
server (ie. a multi-user Access application). The other advantage to using a
query is that you can specify a sort order, so that the items in each combo
box are sorted appropriately.

Tom
_________________________________________

:

Yes, this is what I need. Break it down for me. The combo boxes all had
their own tables. The bound fields on the form were in the same table, and
the form is bound to this table. So I added fields into this table for my
combo boxes and changed the Control Source of each combo box to the
corresponding field in the table. Now the data from the combo boxes is
saved, but not the values I want. Each combo box table has an Autonumber
field that I use to establish the relationships as the first column. This
autonumber value is what is being saved. How can I set it up so the value
that shows in the drop down of the combo box is what is saved?

Thanks!
______________________________________

:

Hi Jen,

Open your form in design view. Click on View > Properties (or press F4 if
using Access 2002 or 2003) to view the properties dialog, if it is not
already displayed. Click on the first combo box. You should see the name of
this control displayed in the blue title bar of the properties display.
Select the Data tab in the properties display. Bind each combo box using the
Control Source property. Click into the Control Source. Click the dropdown
arrow. Select the appropriate field. Your combo box is now considered a bound
control.

Tom
_________________________________________

:

I have 4 unbound combo boxes on a form. (I created them this way before I
realized that unbound controls don't save data in records/tables.) I have
the combo boxes set up and coded how I want but how can I get the form to
save the options I select in the combo boxes? When the value in the combo
boxes changes, it changes in all the saved records.

Thanks!

Jen
 
Top