Is it possible

G

Guest

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks
 
G

Guest

Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

Sprinks said:
Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


Nanette said:
I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



Nanette said:
Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

Sprinks said:
Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


Nanette said:
I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Hi Sprinks,

Hope this explains to you what you need to understand, about what I'm trying
to accomplish.

I have 3 cascading combo boxes. The user selects the first cascading combo
box for one specific RF number. The next cascading combo box (Charge #) now
only shows the specific Charge number options for that specific RF number to
choose from. Once the choice in the 2nd cascading combo box is made, the 3rd
cascading combo box displays all the Line Item options to choose from that
are available to that specific Charge #. Once the Line item number is chosen,
the subform (datasheet view or it could be a continuous form view) is
populated with data.

The data comes from the RF and RF Details tables. There is a one to many
relationship between them with the RF table being the Parent Table. There is
a 3 field primary key in the RF Details table consisting of RF#, Charge#, and
LineItem#. The main form is based on the RF Table and the subform is based on
the RF Details Table.

This actually works quite well at the moment. But it only allows one line of
data to be populated into the subform. I'd like the first choice/line of data
to stay in the sub form, then have the user make the 3 selections again (for
different numbers), and have that new data be added to the subform, below the
first row of data, so that there are now two rows of data in the subform
based on the two requests.

I'm open to any other ways of accomplishing this. My boss wants to be able
to make his three selections from a drop down list to choose a specific line
item. Plus he wants to be able to make several choices. The data is pulled
into a subform so that he can tweak the data if necessary. The data will then
be put into a report for printing.

As an example, he could end up with a form that has the following line items
on it:

RFQ# 1a, Charge # 00, Line item 00111 (several other fields)
RFQ# 1a, Charge # 01, Line item 00222 (several other fields)
RFQ# 1a, Charge # 01, Line item 00333 (several other fields)
RFQ# 1a, Charge # 02, Line item 00111 (several other fields)

There could be many more RFQ# 1a's, but he might not select them this time.
And, there will only be one RFQ# chosen for each form/report. i.e.
THERE WON'T BE:
RFQ# 1a, etc.
RFQ# 2b, etc


Sprinks said:
Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



Nanette said:
Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

Sprinks said:
Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


:

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Nanette,

I think the problem stems from the data model. There are really two
one-to-many relationships: between RFQ# and Charge #, then between Charge#
and LineItem. This is the same type of relationship as in a
Customer->Orders->OrderDetails scenario, which is modeled in the Sample
Northwind database (Help, Sample Databases).

Having a link on all three fields from the RF and RF Detail tables must by
definition permit only one record, since the combination of the 3 must be
unique. IMO, you need another table, RFQCharges that have the RFQID and
Charge# (and whatever other fields are required, specific to the RFQ/Charge
number combination). You can use these two as a compound primary key, or add
an AutoNumber primary key. The latter is my preference in my applications,
but both are valid.

One way to implement the form is what the Orders form in the sample database
does. The main form is based on a query that gives a row for each
combination of Customer and OrderID (analogous to RFQ#/Charge#). As you move
from record to record, you would display the line items in the subform
related to that combination.

Another way is to embed a continuous subform based on LineItems on a main
form based on Charges, linked by the Charge number, then embed the entire
form on a main form based on RFQ#, linked by the RFQ.

Does that make sense?

For reporting, create a query that links the three tables, and use Sorting
and Grouping to output the data in its most convenient form.

Hope that helps.
Sprinks


Nanette said:
Hi Sprinks,

Hope this explains to you what you need to understand, about what I'm trying
to accomplish.

I have 3 cascading combo boxes. The user selects the first cascading combo
box for one specific RF number. The next cascading combo box (Charge #) now
only shows the specific Charge number options for that specific RF number to
choose from. Once the choice in the 2nd cascading combo box is made, the 3rd
cascading combo box displays all the Line Item options to choose from that
are available to that specific Charge #. Once the Line item number is chosen,
the subform (datasheet view or it could be a continuous form view) is
populated with data.

The data comes from the RF and RF Details tables. There is a one to many
relationship between them with the RF table being the Parent Table. There is
a 3 field primary key in the RF Details table consisting of RF#, Charge#, and
LineItem#. The main form is based on the RF Table and the subform is based on
the RF Details Table.

This actually works quite well at the moment. But it only allows one line of
data to be populated into the subform. I'd like the first choice/line of data
to stay in the sub form, then have the user make the 3 selections again (for
different numbers), and have that new data be added to the subform, below the
first row of data, so that there are now two rows of data in the subform
based on the two requests.

I'm open to any other ways of accomplishing this. My boss wants to be able
to make his three selections from a drop down list to choose a specific line
item. Plus he wants to be able to make several choices. The data is pulled
into a subform so that he can tweak the data if necessary. The data will then
be put into a report for printing.

As an example, he could end up with a form that has the following line items
on it:

RFQ# 1a, Charge # 00, Line item 00111 (several other fields)
RFQ# 1a, Charge # 01, Line item 00222 (several other fields)
RFQ# 1a, Charge # 01, Line item 00333 (several other fields)
RFQ# 1a, Charge # 02, Line item 00111 (several other fields)

There could be many more RFQ# 1a's, but he might not select them this time.
And, there will only be one RFQ# chosen for each form/report. i.e.
THERE WON'T BE:
RFQ# 1a, etc.
RFQ# 2b, etc


Sprinks said:
Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



Nanette said:
Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

:

Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


:

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

It sounds to me you need a combo box to select the "RFQ#" (1a) and two
multi-select list boxes to select multiple [Charge #] and multiple [Line
item]. The list box for [Line item] should also have a hidden column for
[Charge #] and a concatenated column of Charge # and Line item. The
concatenated column would be the only visible column.

You would have to create the record source for the form/report or the filter
"on the fly" because you could have multiple "And"s or'ed together that would
look like this:

[RFQ#] = '1a' AND [Charge #] = '00' And [Line item] = '00111' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00222' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00333'

You would also need a button to "update the new filter/record source."

The code for the button would need to loop thru the Items selected in the
2nd list box and create the above filter/ where statement.


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Nanette said:
Hi Sprinks,

Hope this explains to you what you need to understand, about what I'm trying
to accomplish.

I have 3 cascading combo boxes. The user selects the first cascading combo
box for one specific RF number. The next cascading combo box (Charge #) now
only shows the specific Charge number options for that specific RF number to
choose from. Once the choice in the 2nd cascading combo box is made, the 3rd
cascading combo box displays all the Line Item options to choose from that
are available to that specific Charge #. Once the Line item number is chosen,
the subform (datasheet view or it could be a continuous form view) is
populated with data.

The data comes from the RF and RF Details tables. There is a one to many
relationship between them with the RF table being the Parent Table. There is
a 3 field primary key in the RF Details table consisting of RF#, Charge#, and
LineItem#. The main form is based on the RF Table and the subform is based on
the RF Details Table.

This actually works quite well at the moment. But it only allows one line of
data to be populated into the subform. I'd like the first choice/line of data
to stay in the sub form, then have the user make the 3 selections again (for
different numbers), and have that new data be added to the subform, below the
first row of data, so that there are now two rows of data in the subform
based on the two requests.

I'm open to any other ways of accomplishing this. My boss wants to be able
to make his three selections from a drop down list to choose a specific line
item. Plus he wants to be able to make several choices. The data is pulled
into a subform so that he can tweak the data if necessary. The data will then
be put into a report for printing.

As an example, he could end up with a form that has the following line items
on it:

RFQ# 1a, Charge # 00, Line item 00111 (several other fields)
RFQ# 1a, Charge # 01, Line item 00222 (several other fields)
RFQ# 1a, Charge # 01, Line item 00333 (several other fields)
RFQ# 1a, Charge # 02, Line item 00111 (several other fields)

There could be many more RFQ# 1a's, but he might not select them this time.
And, there will only be one RFQ# chosen for each form/report. i.e.
THERE WON'T BE:
RFQ# 1a, etc.
RFQ# 2b, etc


Sprinks said:
Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



Nanette said:
Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

:

Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


:

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Steve,

You understand what I need. I'm curious why the list box for the Line Item
should have a hidden column for the Charge # and a concatenated column also?
How would I create a concatenated column in a list box?

Plus, how would I create a record source for the form/report that works "on
the fly"?

Could you also explain about the code for the button to loop thru the Items
selected in the 2nd list box and create the above filter/ where statement?

I'm a newbie. But, I'm taking a course in VB that starts tonight (don't
remember my VB college work from 3 years ago). I'm assuming VB and VBA are
fairly similar.

SteveS said:
It sounds to me you need a combo box to select the "RFQ#" (1a) and two
multi-select list boxes to select multiple [Charge #] and multiple [Line
item]. The list box for [Line item] should also have a hidden column for
[Charge #] and a concatenated column of Charge # and Line item. The
concatenated column would be the only visible column.

You would have to create the record source for the form/report or the filter
"on the fly" because you could have multiple "And"s or'ed together that would
look like this:

[RFQ#] = '1a' AND [Charge #] = '00' And [Line item] = '00111' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00222' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00333'

You would also need a button to "update the new filter/record source."

The code for the button would need to loop thru the Items selected in the
2nd list box and create the above filter/ where statement.


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Nanette said:
Hi Sprinks,

Hope this explains to you what you need to understand, about what I'm trying
to accomplish.

I have 3 cascading combo boxes. The user selects the first cascading combo
box for one specific RF number. The next cascading combo box (Charge #) now
only shows the specific Charge number options for that specific RF number to
choose from. Once the choice in the 2nd cascading combo box is made, the 3rd
cascading combo box displays all the Line Item options to choose from that
are available to that specific Charge #. Once the Line item number is chosen,
the subform (datasheet view or it could be a continuous form view) is
populated with data.

The data comes from the RF and RF Details tables. There is a one to many
relationship between them with the RF table being the Parent Table. There is
a 3 field primary key in the RF Details table consisting of RF#, Charge#, and
LineItem#. The main form is based on the RF Table and the subform is based on
the RF Details Table.

This actually works quite well at the moment. But it only allows one line of
data to be populated into the subform. I'd like the first choice/line of data
to stay in the sub form, then have the user make the 3 selections again (for
different numbers), and have that new data be added to the subform, below the
first row of data, so that there are now two rows of data in the subform
based on the two requests.

I'm open to any other ways of accomplishing this. My boss wants to be able
to make his three selections from a drop down list to choose a specific line
item. Plus he wants to be able to make several choices. The data is pulled
into a subform so that he can tweak the data if necessary. The data will then
be put into a report for printing.

As an example, he could end up with a form that has the following line items
on it:

RFQ# 1a, Charge # 00, Line item 00111 (several other fields)
RFQ# 1a, Charge # 01, Line item 00222 (several other fields)
RFQ# 1a, Charge # 01, Line item 00333 (several other fields)
RFQ# 1a, Charge # 02, Line item 00111 (several other fields)

There could be many more RFQ# 1a's, but he might not select them this time.
And, there will only be one RFQ# chosen for each form/report. i.e.
THERE WON'T BE:
RFQ# 1a, etc.
RFQ# 2b, etc


Sprinks said:
Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



:

Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

:

Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


:

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Hi again Steve,

I also just thought of something. I could have only one list box that could
offer the user only the charge #s and line item #s that are available to the
specific RFQ number in the combo box. Wouldn't really need two list boxes.
The user would still need to be able to choose several charge#/line item#'s,
have that data be pulled from a table, and have those lines go into a
form/subform.

SteveS said:
It sounds to me you need a combo box to select the "RFQ#" (1a) and two
multi-select list boxes to select multiple [Charge #] and multiple [Line
item]. The list box for [Line item] should also have a hidden column for
[Charge #] and a concatenated column of Charge # and Line item. The
concatenated column would be the only visible column.

You would have to create the record source for the form/report or the filter
"on the fly" because you could have multiple "And"s or'ed together that would
look like this:

[RFQ#] = '1a' AND [Charge #] = '00' And [Line item] = '00111' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00222' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00333'

You would also need a button to "update the new filter/record source."

The code for the button would need to loop thru the Items selected in the
2nd list box and create the above filter/ where statement.


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Nanette said:
Hi Sprinks,

Hope this explains to you what you need to understand, about what I'm trying
to accomplish.

I have 3 cascading combo boxes. The user selects the first cascading combo
box for one specific RF number. The next cascading combo box (Charge #) now
only shows the specific Charge number options for that specific RF number to
choose from. Once the choice in the 2nd cascading combo box is made, the 3rd
cascading combo box displays all the Line Item options to choose from that
are available to that specific Charge #. Once the Line item number is chosen,
the subform (datasheet view or it could be a continuous form view) is
populated with data.

The data comes from the RF and RF Details tables. There is a one to many
relationship between them with the RF table being the Parent Table. There is
a 3 field primary key in the RF Details table consisting of RF#, Charge#, and
LineItem#. The main form is based on the RF Table and the subform is based on
the RF Details Table.

This actually works quite well at the moment. But it only allows one line of
data to be populated into the subform. I'd like the first choice/line of data
to stay in the sub form, then have the user make the 3 selections again (for
different numbers), and have that new data be added to the subform, below the
first row of data, so that there are now two rows of data in the subform
based on the two requests.

I'm open to any other ways of accomplishing this. My boss wants to be able
to make his three selections from a drop down list to choose a specific line
item. Plus he wants to be able to make several choices. The data is pulled
into a subform so that he can tweak the data if necessary. The data will then
be put into a report for printing.

As an example, he could end up with a form that has the following line items
on it:

RFQ# 1a, Charge # 00, Line item 00111 (several other fields)
RFQ# 1a, Charge # 01, Line item 00222 (several other fields)
RFQ# 1a, Charge # 01, Line item 00333 (several other fields)
RFQ# 1a, Charge # 02, Line item 00111 (several other fields)

There could be many more RFQ# 1a's, but he might not select them this time.
And, there will only be one RFQ# chosen for each form/report. i.e.
THERE WON'T BE:
RFQ# 1a, etc.
RFQ# 2b, etc


Sprinks said:
Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



:

Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

:

Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


:

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Even better!

--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Nanette said:
Hi again Steve,

I also just thought of something. I could have only one list box that could
offer the user only the charge #s and line item #s that are available to the
specific RFQ number in the combo box. Wouldn't really need two list boxes.
The user would still need to be able to choose several charge#/line item#'s,
have that data be pulled from a table, and have those lines go into a
form/subform.

SteveS said:
It sounds to me you need a combo box to select the "RFQ#" (1a) and two
multi-select list boxes to select multiple [Charge #] and multiple [Line
item]. The list box for [Line item] should also have a hidden column for
[Charge #] and a concatenated column of Charge # and Line item. The
concatenated column would be the only visible column.

You would have to create the record source for the form/report or the filter
"on the fly" because you could have multiple "And"s or'ed together that would
look like this:

[RFQ#] = '1a' AND [Charge #] = '00' And [Line item] = '00111' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00222' OR
[RFQ#] = '1a' AND [Charge #] = '01' AND [Line item] = '00333'

You would also need a button to "update the new filter/record source."

The code for the button would need to loop thru the Items selected in the
2nd list box and create the above filter/ where statement.


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Nanette said:
Hi Sprinks,

Hope this explains to you what you need to understand, about what I'm trying
to accomplish.

I have 3 cascading combo boxes. The user selects the first cascading combo
box for one specific RF number. The next cascading combo box (Charge #) now
only shows the specific Charge number options for that specific RF number to
choose from. Once the choice in the 2nd cascading combo box is made, the 3rd
cascading combo box displays all the Line Item options to choose from that
are available to that specific Charge #. Once the Line item number is chosen,
the subform (datasheet view or it could be a continuous form view) is
populated with data.

The data comes from the RF and RF Details tables. There is a one to many
relationship between them with the RF table being the Parent Table. There is
a 3 field primary key in the RF Details table consisting of RF#, Charge#, and
LineItem#. The main form is based on the RF Table and the subform is based on
the RF Details Table.

This actually works quite well at the moment. But it only allows one line of
data to be populated into the subform. I'd like the first choice/line of data
to stay in the sub form, then have the user make the 3 selections again (for
different numbers), and have that new data be added to the subform, below the
first row of data, so that there are now two rows of data in the subform
based on the two requests.

I'm open to any other ways of accomplishing this. My boss wants to be able
to make his three selections from a drop down list to choose a specific line
item. Plus he wants to be able to make several choices. The data is pulled
into a subform so that he can tweak the data if necessary. The data will then
be put into a report for printing.

As an example, he could end up with a form that has the following line items
on it:

RFQ# 1a, Charge # 00, Line item 00111 (several other fields)
RFQ# 1a, Charge # 01, Line item 00222 (several other fields)
RFQ# 1a, Charge # 01, Line item 00333 (several other fields)
RFQ# 1a, Charge # 02, Line item 00111 (several other fields)

There could be many more RFQ# 1a's, but he might not select them this time.
And, there will only be one RFQ# chosen for each form/report. i.e.
THERE WON'T BE:
RFQ# 1a, etc.
RFQ# 2b, etc


:

Nanette,

I think it will be easier if we step back from the form and discuss the
tables underlying the main and subforms, the relationships between them, and
a generic description of the purpose of the database. What do you mean by
the choices in the three combo boxes "populating" the subform? Are they the
LinkMasterFields to corresponding fields in the subform's underlying
RecordSource? Or something else?

It sounds from what you're describing that you're interested in having a
continuous main form with an embedded datasheet. This is not possible in
Access, but if I understand your table structures and what you're trying to
do, I may be able to suggest another way of accomplishing it.



:

Hi Sprinks,

I'm not sure if setting the default is what I want. Let me explain further.

I would like the user to make a choice in the 1st (RFQ #), 2nd (Change #),
and 3rd (Line Item #) combo boxes. This will populate the subform.

Then, I want the user to be able to make another choice in the 2nd, and 3rd
combo boxes (for what I'm doing, the 1st combo box will always contain the
same RFQ # for the additional choices). This data would then be added to the
subform as a 2nd row of data. The 1st choice and 2nd choice would now be in
the form.
Example:
First Choice:
RFQ #: AA
Change #: 12
Line #: 23

2nd Choice:
RFQ: AA
Change #: 12
Line #: 27

3rd Choice
RFQ: AA
Change #: 45
Line #: 13

I want the user to be able to continue adding rows of data based by picking
options from the 3 combo boxes and each choice would appear below the last
choice in the form.

I guess you could say it's something like a shopping list.

Knowing this, would setting the default in the 1st combo box be the correct
thing to do?

:

Nanette,

As it's always possible to add multiple rows to a form in Datasheet view,
I'm not sure what you're asking. Are you saying that you'd like whatever
value you've entered in the first combo box to become the default value for
subsequent rows?

If so, use the AfterUpdate event of the first combo box to set its
DefaultValue property:

Me![YourComboBox].DefaultValue = Me![YourComboBox]

Hope that helps.
Sprinks


:

I have three cascading combo boxes that populate a form. It's working great.
The form is in datasheet view.

Is it possible to change it so that the first selection stays in the form,
and the user can choose another row of data from the 3 cascading combo boxes
that can be added to the form so that now two rows of data are there?

If this is possible, I'd like to make it so that the user can add several
rows of data.
 
G

Guest

Nanette said:
Steve,

You understand what I need. I'm curious why the list box for the Line Item
should have a hidden column for the Charge # and a concatenated column also?
How would I create a concatenated column in a list box?

To limit the "Line Item" records based on the "Charge#"s selected. Hidded
because I was thinking of combo box instead of List box... <slap>. To create
a concatenated column (LB or Combo), in the rowsource query, you would write
something like:

ChargeItem: [Charge#] & "-" & [LineItem]

As you said in the other post, you could use a single list box to show both
the chage # and the associated line item. This way, you *will* have to
generate the recordsource SQL "on-the-fly" (in code).

Plus, how would I create a record source for the form/report that works "on
the fly"?

Could you also explain about the code for the button to loop thru the Items
selected in the 2nd list box and create the above filter/ where statement?

On the main form you have a combo box to select the RFQ# and list box to
select the Charge# and Line Item.
Lets call the combo box "cboRFQ" and the list box "ChargeItemList". And
lets call the button "ShowMe".

It sounds like there is a subform that has the results of the query. The
subform would have a recordsource (a query) that would look something like
(to start out with):

SELECT [RFQ#], [Charge#], [LineItem] FROM RF_Details WHERE [RFQ#] = &
Forms![MyRFQForm.cboRFQ

At this point, the subform would (should) have the same rows as the listbox.
But a query cannot have multiple criteria unless you want to edit the query
each time you want to use different criteria (charge# and line items). So you
have to generate a SQL string in code....but let the computer do the work.

Now some code for the button. To start out, the code would be:

Private Sub ShowMe_Click()
Dim strSQL As String

strSQL = "SELECT [RFQ#], [Charge#], [LineItem] FROM RF_Details WHERE
[RFQ#] = & Forms![MyRFQForm.cboRFQ"

End Sub


Not very useful yet. So let's add more criteria from the list box. To get
the Charge# and the LineItem we need to know which columns in the list box
that they are in.

Here is an example of the code you might use to set the recordsource of a
subform (that is not linked to the main form).

*** some air code

***watch for line wrap

'---------beg code--------------------------
Private Sub ShowMe_Click()
Dim strSQL As String

Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim intI As Integer
Dim k As Integer
Dim x As Integer

' make changes here
'-----------------------------------------------
' use your form name
Set frm = Forms!MyRFQForm

' use your listbox name
Set ctl = frm!ChargeItems_listbox

strSQL = "SELECT [RFQ#], [Charge#], [LineItem] FROM RF_Details WHERE
[RFQ#] = '" & frm.cboRFQ & "' "
'-----------------------------------------------

'k = number of rows selected in list box
k = ctl.ItemsSelected.Count

'x = count of number of times thru the FOR EACH...NEXT loop
x = 1

If k > 0 Then
'add opening paren
strSQL = strSQL & " AND ("

For Each varItm In ctl.ItemsSelected
'change the the 0 and 1 in the following line to the column numbers
' for Charge# and LineItem in yourlistbox
strSQL = strSQL & "([Charge#] = '" & ctl.Column(0, varItm) & "'
AND [LineItem] = '" & ctl.Column(1, varItm) & "' "

If x < k Then
strSQL = strSQL & ") OR "
End If

'add closing parens
If x = k Then
strSQL = strSQL & "))"
End If

'inc x
x = x + 1

Next varItm
End If

'-----------------------------------------------
' this is where you would set the subform recordsource = to strSQL
'something like:

' Me.SubFormName.recordsource = strSQL


'using your object names of course
'-----------------------------------------------

Debug.Print strSQL

End Sub

'----------end code-----------------

I'm a newbie. But, I'm taking a course in VB that starts tonight (don't
remember my VB college work from 3 years ago). I'm assuming VB and VBA are
fairly similar.

Yes, I think VBA is a sub-set of VB.


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top