Creating Sub Item in Access

M

Maulwy

Dear All,

I have a table A, which consists of the field "ID" and "QTY", and Table B,
which consists of "ID2" and "Details". "ID" is AutoNumber. At the time of the
input data using a form field "QTY" to number 2, then automatically, on the
table B, increased 2 lines, where the field "ID2" contains the number "001-1"
and "001-2", where "001" comes from "ID" and "-1" and "-2" comes from "QTY" =
2. If the next record, in the "QTY" I input 3, then the "ID2" = "002-1",
"002-2", 002-3 ".
The question is, how do I make this in Access?
Thank you in advance.

Rgds,
Maulwy
 
J

Jeff Boyce

First off, you probably wouldn't need to ...

The notion of a relational database is that you can put records in your
tableB that are related to records in your tableA. You would have a field
in tableB to hold a "foreign key" (check Access HELP if this term is
unfamiliar) that points back to the ID from tableA that "owns" the record in
tableB.

If you are trying to introduce formatting like "001-1", "001-2", etc., use a
query to join the tables and display values from those two tables to look
like that.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
M

Maulwy

Dear Jeff,

Basically, my desire is the existence of a function that limits the number
of rows in Table B based on the amount that has been input in table A.
Examples of cases, delivery order transactions, in the master transaction
(Table A), has been input 2 goal posts. If this transaction commits,
automatically, the program adds 2 new lines in Table B, which will be used to
fill the delivery destination address. So, what will be input in Table A,
will limit the number of rows in Table B. When I use a sub form, it can not
restrict it. What I want, Table B is a detail of Table A, where the number of
rows in Table B, depending on what the inputs in table A, so that users can
not be input to more / less than what has been input in Table A . Almost the
same as the sub form, only the number of rows in the sub form, depending on
the amount that has been input in Table A.
Thank you in advance.
 
J

Jeff Boyce

It is rarely necessary (and most often not advised) to create empty "dummy"
records for such parent/child relationships.

The more common approach is to use a main form/subform design, add related
"child" records to a parent, but check the parent record to get the maximum
number of children allowed.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

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