I may have misunderstood your description...
It sounds like you have tables with the same (identical) structure, but used
to hold different "types" of (?)invoicing.
If this is your situation, your database is a spreadsheet! In a relational
database like Access, you'd use a single table with the fields, then add one
more to indicate "type".
I'm not confident yet that I understand your table structure, and in Access,
it all starts with the data. "How" depends on "what".
Could you post back a simple table structure description? For example, a
very rudimentary student enrollment data structure might look like:
tblStudent
StudentID
FirstName
LastName
DateOfBirth
tblClass
ClassID
ClassTitle
ClassDescription
trelEnrollment
EnrollmentID
StudentID
ClassID
EnrollmentDate
--
Regards
Jeff Boyce
www.InformationFutures.net
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
thank your for reply
my db is just a developed copy of the sample db "expense reports" which
comes with the windows office .the table "employees " has been renamed to
"Patients" and added /deleted many other fiels to match our needs.
first of all , instead of the two tables called "expense reports
","expense
details"
I have four tables ,which are these two plus another two tables
,"cashPaymentvouchers",Invoice
each table has its primary key
1.CashPaymentVouchers---CpvId
2.Invoices---InvoiceId
3.Expense Reports---ExpenseReportId
4.Expense Details---ExpensedetailId
the reason for adding the other two table is the following
my job is receiving , checking and accounting Invoices that belongs to
Patients treatment,Patients tickets ,etc.
our system is to add a record in the main table "Patients" for each type
we
send the patient abroad for treatment.the primary key for this table is
Caseid
we are sending patients to more than 20 countries , and in some of these
countries we receive the invoice directly , others we receive them thru
our
embassies in those countries
in the cases of invoices received thru our embassies , the embassy we pay
the bill ,we attach bill, draft copy or chq copy to a cash payment voucher
(CPV)
they will send the bill fortnightly , along with a covering letter , lets
call it a batch , so one batch will contain many cpv's , one cpv may
contain
many invoices , one invoice may belongs to more than one case
in order to enter each cpv one time only , and to enter each invoice one
time only , I have added these two table "cashpaymentvouchers","invoices"
apart from this , I have a fifth table which is called "Invoice Register"
this table is used to enter the data for each batch like batch number ,
country, batch amount , currency ,date received , date sent for payment.
when we arrange to send patient abroad , at this point I will add a record
to the table "Patients" which off course will include Travel date ,
country
of treatment , Hospital etc.
some of the expenses like advance allowances given to patient ,will be
accounted before the travel of the patient, these will not be entered in
the
Invoice Register, as there are no invoice here , but there are cpv , so ,
I
will first till you what i do in this case , then I will till you how I
enter
the Invoice details
we have arranged to sent a patient abroad
1.I will open the form"Expense reports by patient" source
atients
table,this form got a subform "Patients subform", which will show the list
of
expenses for the patient.(the source of this subform is a union query for
the
four tables:cpv,invoice,Expense report,Expense details)
here I have a button when clicked will open another form
"Cashpaymentvouchers", with its subform"cpv subform" .source for the first
is
table cpv , souce of the 2nd is table "invoices.
my question was about this stage here , the form "CashPaymentVouchers"
source is this :SELECT DISTINCTROW [CashPaymentVouchers].* FROM
CashPaymentVouchers WHERE (([CashPaymentVouchers].Batchid=forms![Invoices
Register]!Batchid)) order by cpvid;
the code which I gave is in the on activate event of this form,when i open
,
i want it to go to the same cpv which was selected thru the
subform"patients
subform", and ALSO, to go to the same InvoiceId that was selected there,
off
course it cannot go directly to the invoiceid , first we have to select
the
cpv that this invoiceid is in.
so, now when i open the cashpaymentvouchers form , it will take me to