Very simple problem with Forms and Combo Boxes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Yet for some reason, I am having major problems with it. It has been a
while since I've created a DB from scratch, and it seems I've forgotten
everything I once knew.

Anyway, onto my problem....

I've got a form that I want to use for data entry. On this form, I have
two combo boxes (let's say one is for type of fruit, and the other is for
country of origin). The user will pull down on the first combo box and
select a fruit, and then pull down on the second box to select a country.
Once they have done that, they can then choose a from a variety of attibutes
(since I have many attributes, I've made them all yes/no radio buttons).
Anyway, once the user has selected all of the attributes for that fruit from
that country, they can progress onto other items or close the form.

The attributes for each fruit from each country will be stored in another
table, and the options being pulled down for each combo box are stored in
separate tables and sorted appropriately.

For some reason, nothing is working. I can pull down any combination of the
combo boxes, but the data is not being stored in the "final destination"
table. Any ideas? I know this is a simple problem, but I think I've
completely lost my mind looking at this problem.

Thanks,
 
Yet for some reason, I am having major problems with it. It has been a
while since I've created a DB from scratch, and it seems I've forgotten
everything I once knew.

Anyway, onto my problem....

I've got a form that I want to use for data entry. On this form, I have
two combo boxes (let's say one is for type of fruit, and the other is for
country of origin). The user will pull down on the first combo box and
select a fruit, and then pull down on the second box to select a country.
Once they have done that, they can then choose a from a variety of attibutes
(since I have many attributes, I've made them all yes/no radio buttons).

Tables do not contain radio buttons, and Forms do not contain data.

Have you set all these Attributes as Yes/No fields in a table? Or do
you have a second table in a one-to-many relationship?
Anyway, once the user has selected all of the attributes for that fruit from
that country, they can progress onto other items or close the form.

The attributes for each fruit from each country will be stored in another
table, and the options being pulled down for each combo box are stored in
separate tables and sorted appropriately.

For some reason, nothing is working. I can pull down any combination of the
combo boxes, but the data is not being stored in the "final destination"
table. Any ideas? I know this is a simple problem, but I think I've
completely lost my mind looking at this problem.

What is the Recordsource property of the Form?
What are the Control Source properties of the combo boxes?
What are the Control Source properties of the buttons?
Have you considered a Form (based on the "fruits" table) with a
Subform (based on a many-to-many resolver table with fields for the
FruitID and the attribute, with a Combo Box based on a table of
attributes to store the attribute)?

John W. Vinson[MVP]
 
John5359 said:
Yet for some reason, I am having major problems with it. It has
been a while since I've created a DB from scratch, and it seems I've
forgotten everything I once knew.

Anyway, onto my problem....

I've got a form that I want to use for data entry. On this form, I
have two combo boxes (let's say one is for type of fruit, and the
other is for country of origin). The user will pull down on the
first combo box and select a fruit, and then pull down on the second
box to select a country. Once they have done that, they can then
choose a from a variety of attibutes (since I have many attributes,
I've made them all yes/no radio buttons). Anyway, once the user has
selected all of the attributes for that fruit from that country, they
can progress onto other items or close the form.

The attributes for each fruit from each country will be stored in
another table, and the options being pulled down for each combo box
are stored in separate tables and sorted appropriately.

For some reason, nothing is working. I can pull down any combination
of the combo boxes, but the data is not being stored in the "final
destination" table. Any ideas? I know this is a simple problem,
but I think I've completely lost my mind looking at this problem.

First and most basic question: Is your form bound to the table, or to a
query of it? What's the form's RecordSource property, as shown on the
Data tab of the form's property sheet in Design View?

Second question: Are the various controls on the form bound to fields
in the form's RecordSource? Are their ControlSource properties blank?

Third question: Are the form's AllowEdits and AllowAdditions properties
set to Yes?

Fourth question: If the form's RecordSource is a query, is that query
updatable? That is, if you open the query directly as a datasheet, can
you edit and add records on it?
 
Thanks for the help guys. I didn't "bind" the fields, and thus any record I
added to the table would only have the attributes and not list the fruit or
the country selected. Talk about me screwing up a very basic fundamental
issue. But now I'm having another problem:

When I am in the form (still in testing mode) and randomly generating fruits
and countries and attributes, I can input the same fruit and country (as
another record) and choose different attributes. I would like to set it up
so that there can only be one scenario (Fruit X and country Y will only have
one set of attributes). In other words, if the user selects "banana" and
"Guatemala", the form should either generate a new record or call up any
attributes previously saved for that particular fruit-country combination.
Since there will be a lot of entries in this database, I can' t have the user
search through all of the listings to see what's been put in before (i.e.
record # 57 out of 425).

Now that I think about it, it has been about 7 years since I last made a
database, so I am pretty much starting back at square one. Any ideas on how
to make the fruit-country combinations unique?

Thanks again for helping out a "recycled" newbie,
 
Any ideas on how
to make the fruit-country combinations unique?

Create a unique Index on the two fields in table design view. Either
Ctrl-click the two fields and then click the Key icon to make them a
joint Primary Key, or use the Indexes icon on the toolbar.

John W. Vinson[MVP]
 
Thanks for the joint-primary key help. It works. Now, if I can just get it
to pull up previously entered fruit-country combinations, it would be
perfect. Somebody in the office suggested I use "requery", but didn't know
enough about it to point me in a direction. I'll see what the help menus
have on it. Thanks again,
 
Thanks for the joint-primary key help. It works. Now, if I can just get it
to pull up previously entered fruit-country combinations, it would be
perfect. Somebody in the office suggested I use "requery", but didn't know
enough about it to point me in a direction. I'll see what the help menus
have on it. Thanks again,

Requery just reruns the query upon which a form (or control) is based,
so that if the data in the table has changed you see all the current
data. Not relevant to this issue.

You might try "Query by Form" (use the binoculars on the toolbar), or
you can have some VBA code to set the form's Filter property based on
the values selected in two

*** UNBOUND ***

combo boxes, say in the form's header. It's important to use unbound
combos because otherwise you'll overwrite the currently displayed
record's fields with the values you're trying to find. Sample code
(say in a Click event of a "Find It" button):

Private Sub cmdFind_Click()
Dim strSQL As String
strSQL = "True "
If Not IsNull(Me!cboFindCountry) Then
strSQL = strSQL & " AND [Country] = '" & Me!cboFindCountry & "' "
End If
If Not IsNull(Me!cboFindFruit) Then
strSQL = strSQL & " AND [Fruit] = '" & Me!cboFindFruit & "'"
End If
Me.Filter = strSQL
Me.FilterOn = True
End Sub


John W. Vinson[MVP]
 
Back
Top