both forms are based on tables.
The main table is where I enter the contract number, create an invoice number,
enter customer information.
So the real-life Entity (person, thing or event) modeled by the main table is
an Invoice? Is it a fair statement that you do not want or expect repeat
business, so that once you issue an invoice to a customer you'll never see
that customer again, or else reenter that customer's information redundantly
if they DO come back?
The subform is where I enter all the items for which I bill the customer. It
could be one item or more.
Then I print out the invoice which lists all the items for that invoice
number and the total ammount billed.
The record source of the subform has the following fields and the name of the
fields on the form are also the same respectively.
txtInvoice, txtIDexcription, txtQty, txtUnit, txtUnitPrice, txtTotal
I would suggest that you NOT store the total: if txtTotal is the product of
txtQty and txtUnitPrice then it should be dynamically calculated as needed and
NOT stored in any table.
Do you have a table of Items? or do you reenter the description anew for every
invoice-detail item? Are the items one of a kind, or do you sell "the same"
item to multiple customers?
the txtInvoice is the PK of the main form, however it is not a PK on the
subform. The subform does not have a PK.
Forms do NOT HAVE PRIMARY KEYS.
Forms DO NOT STORE DATA.
Forms are *just windows*, tools to manage data in tables. I really suspect
you're mixing levels here.
How then do you uniquely identify an item on the subform's table? Nothing to
prevent duplicate records?
Do you have a Relationship defined between the two tables (on txtInvoice)?
Should I base my forms on a query based on the two tables?
No. The mainform should be based on the parent table, the subform on the
details table.
I can't figure out why the form shows different records with the same info
for the same invoice. The number of the records depend of the number of
records entered in the subform.
Without knowing what data is in your tables, and what you're seeing on the
form, I really don't know - other than to say that it's possible that your
tables or relationships may not be set up correctly.