I'm trying to create a field that populates a choice of selections based on
what was selected in a prior field. For examples sake: categories and
sub-categories. I'm having trouble with coding the form to say "based on
your selection in the category field, your options in the sub-category field
are..." How would I go about this? Thanks!
|
|
0
|
|
|
|
Reply
|
Utf
|
3/9/2010 4:38:01 PM |
|
You mean like a combo box? Well... for the subcatagory, each possible choice
is ideally stored in a table that has a field that also references when the
catagory is. For instance:
tblCatagories might have a field called fldCatagory with these records:
Fruits
Veggies
Grains
and tblSubCats would have two fields, a link to it's parent (fldCat) and the
selection item (fldFood)...
Fruits|Apples
Fruits|Oranges
Veggies|Tomatoes
Veggies|Carrots
Grains|Bread
Grains|Oats
So if you have two combo boxes, the first has a recordsource directly
related to tblCatagories.
The second one is dynamic based on the first combo... it's recordsource will
be tblSubCats, but you want to filter them based on the selected catagory.
To do this, set the AfterUpdate event of the first combo to requery the
second combo based on the selection (you'll also want this in the Current
event of the form so the selections are correct for each record you navigate
to).
Private Sub cboCatagories_AfterUpdate()
Me.cboSubCat.RowSource = _
"SELECT * FROM tblSubCats " & _
"WHERE fldCat = """ & Nz(Me.cboCat, "") & """"
End Sub
something along those lines...
hth
--
Jack Leach
www.tristatemachine.com
"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
"TheDrescher" wrote:
> I'm trying to create a field that populates a choice of selections based on
> what was selected in a prior field. For examples sake: categories and
> sub-categories. I'm having trouble with coding the form to say "based on
> your selection in the category field, your options in the sub-category field
> are..." How would I go about this? Thanks!
|
|
0
|
|
|
|
Reply
|
Utf
|
3/9/2010 5:18:01 PM
|
|
Jack,
Thanks for the information! I'm running into a snag when I test the form:
When I select a category, I recieve a "Compile error: method or data member
not found".
The tables and info I created are the same as in your example. The code as
written in my VBA window is:
Private Sub Categories_AfterUpdate()
Me.cboSubCat.RowSource = "SELECT * FROM tblSubCats " & "WHERE FldCat = """
& Nz(Me.cboCat, "") & """"
End Sub
When the error populates, it highlights the .cboCat near the end. Any
suggestions?
"Jack Leach" wrote:
> You mean like a combo box? Well... for the subcatagory, each possible choice
> is ideally stored in a table that has a field that also references when the
> catagory is. For instance:
>
> tblCatagories might have a field called fldCatagory with these records:
> Fruits
> Veggies
> Grains
>
> and tblSubCats would have two fields, a link to it's parent (fldCat) and the
> selection item (fldFood)...
> Fruits|Apples
> Fruits|Oranges
> Veggies|Tomatoes
> Veggies|Carrots
> Grains|Bread
> Grains|Oats
>
> So if you have two combo boxes, the first has a recordsource directly
> related to tblCatagories.
>
> The second one is dynamic based on the first combo... it's recordsource will
> be tblSubCats, but you want to filter them based on the selected catagory.
>
> To do this, set the AfterUpdate event of the first combo to requery the
> second combo based on the selection (you'll also want this in the Current
> event of the form so the selections are correct for each record you navigate
> to).
>
>
> Private Sub cboCatagories_AfterUpdate()
> Me.cboSubCat.RowSource = _
> "SELECT * FROM tblSubCats " & _
> "WHERE fldCat = """ & Nz(Me.cboCat, "") & """"
> End Sub
>
>
> something along those lines...
>
> hth
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven''t failed, I''ve found ten thousand ways that don''t work."
> -Thomas Edison (1847-1931)
>
>
>
> "TheDrescher" wrote:
>
> > I'm trying to create a field that populates a choice of selections based on
> > what was selected in a prior field. For examples sake: categories and
> > sub-categories. I'm having trouble with coding the form to say "based on
> > your selection in the category field, your options in the sub-category field
> > are..." How would I go about this? Thanks!
|
|
0
|
|
|
|
Reply
|
Utf
|
3/10/2010 4:15:01 PM
|
|
Okay, I think I've worked most of way through the code to get 90% there, but
when I bring up the category, I now get this error:
"The record source 'SELECT*FROM tblSubCats WHERE FldCategory = "1"'
specified on this form or report does not exist."
I've tried doing some renaming and shuffling, but I keep coming back with
the same error. I even created a relationship between the category fields of
the two tables and i'm still getting the same message. The two related
tables are 'Categories' and 'SubCats' with the related field between the two
simply named 'Category". Is there something else I'm missing? Thanks again
for your help.
"TheDrescher" wrote:
> Jack,
>
> Thanks for the information! I'm running into a snag when I test the form:
> When I select a category, I recieve a "Compile error: method or data member
> not found".
> The tables and info I created are the same as in your example. The code as
> written in my VBA window is:
>
> Private Sub Categories_AfterUpdate()
> Me.cboSubCat.RowSource = "SELECT * FROM tblSubCats " & "WHERE FldCat = """
> & Nz(Me.cboCat, "") & """"
>
> End Sub
>
> When the error populates, it highlights the .cboCat near the end. Any
> suggestions?
>
> "Jack Leach" wrote:
>
> > You mean like a combo box? Well... for the subcatagory, each possible choice
> > is ideally stored in a table that has a field that also references when the
> > catagory is. For instance:
> >
> > tblCatagories might have a field called fldCatagory with these records:
> > Fruits
> > Veggies
> > Grains
> >
> > and tblSubCats would have two fields, a link to it's parent (fldCat) and the
> > selection item (fldFood)...
> > Fruits|Apples
> > Fruits|Oranges
> > Veggies|Tomatoes
> > Veggies|Carrots
> > Grains|Bread
> > Grains|Oats
> >
> > So if you have two combo boxes, the first has a recordsource directly
> > related to tblCatagories.
> >
> > The second one is dynamic based on the first combo... it's recordsource will
> > be tblSubCats, but you want to filter them based on the selected catagory.
> >
> > To do this, set the AfterUpdate event of the first combo to requery the
> > second combo based on the selection (you'll also want this in the Current
> > event of the form so the selections are correct for each record you navigate
> > to).
> >
> >
> > Private Sub cboCatagories_AfterUpdate()
> > Me.cboSubCat.RowSource = _
> > "SELECT * FROM tblSubCats " & _
> > "WHERE fldCat = """ & Nz(Me.cboCat, "") & """"
> > End Sub
> >
> >
> > something along those lines...
> >
> > hth
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven''t failed, I''ve found ten thousand ways that don''t work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "TheDrescher" wrote:
> >
> > > I'm trying to create a field that populates a choice of selections based on
> > > what was selected in a prior field. For examples sake: categories and
> > > sub-categories. I'm having trouble with coding the form to say "based on
> > > your selection in the category field, your options in the sub-category field
> > > are..." How would I go about this? Thanks!
|
|
0
|
|
|
|
Reply
|
Utf
|
3/10/2010 8:38:09 PM
|
|
|
3 Replies
153 Views
(page loaded in 0.07 seconds)
Similiar Articles: Conditional Appearance of Form Sections Based on Option/Radio ...field), which when selected/changed, creates another fieldset of controls whose count is based on the selection. ... based, on, checkbox, selection ... conditional ... conditional update of checkbox dependent on combo box in separate ...... checkbox from FALSE to TRUE based on the selection ... with the name of the form / field in ... Make checkboxes invisibile based on combo box selection ... conditional update ... Change field format based on condition - microsoft.public.access ...Microsoft Access: Change field format based on condition ... database.itags.org: Microsoft Access question: Change field format based on condition, created at:Fri, 30 May ... Formatting phone field based on value in another field - microsoft ...Formatting phone field based on value in another field - microsoft ... Change field format based on condition - microsoft.public.access ... How can I Enable a Check Box ... Conditional Formatting - Comparing field on form to field on a ...Conditional Formatting In a Datasheet Form - microsoft.public ..... format like so, Condition1 “Field Value Is ... need 4 conditional formats based on a percentage ... print fields based on conditions/criteria - microsoft.public ...Updating Yes/No table field based after form input completed ... ... data in Excel based on multiple criteria for one field ... I have cells that, based on the condition ... Conditional formatting based on Column header - microsoft.public ...Then Conditional Format the Quantities field for the current month using the Expression Is ... Conditional Format based on Month of Date in Cell - microsoft ... Conditional ... ACCESS - can i display a field if a condition is met in another fi ...ACCESS - can i display a field if a condition is met in another fi ... Hide Field based on Another - microsoft.public.access.forms ... Ho to make one field required based ... Conditional Formatting - Turning on a label field - microsoft ...I'm not ure how to set up the conditional formatting to make visible another field based on the value of another. Thanks in advance for help Kenny A. Show sum based on selection from Combo Box - Help Please ...Auto populate form field based on selection - microsoft.public ..... field based on ... conditional update of checkbox dependent on combo box in separate ... ... Microsoft Word: Creating conditional field based on selection from ...offer letter template, ref field, exit option: You will need to use an IF field with a REF field {IF {Ref Dropdown1} = a one two \* MERGEFORMAT} obviously you ... Conditional Appearance of Form Sections Based on Option/Radio ...field), which when selected/changed, creates another fieldset of controls whose count is based on the selection. ... based, on, checkbox, selection ... conditional ... Conditional Appearance of Form Sections Based on Option/Radio ...Word - Conditional Appearance of Form Sections Based on Option/Radio Selections ... name:"), and of course field ... whose count is based on the selection. I ... Conditional Fields | drupal.orgThe conditional fields settings in the field edit page will appear only if there are other ... site here but I'm not understanding how to set up a conditional based ... Creating Conditional Value Lists | FileMakerCreate at least one value list based on values in a field; Format a field on a layout to display a value list; Creating a conditional value list requires the creation of a ... 7/11/2012 9:15:52 PM
|