Subform/Form Question

  • Thread starter Thread starter Salisha Khan
  • Start date Start date
S

Salisha Khan

hey everyone,
i got a question. i have a unbound from and a bound subform. in the
form i enter info about a car that is taken in for repair and the subform
list the various services that was performed on car at the time of repair.
so i have two tables. the main table is tblExpense and the next table is
tblExpenseDetails. Ok so to save the data from the main form and subform
into the appropriate tables, i have written code behind a save command
button. the problem is, say i want to delete the data i am entering, i have
a delete command button that works perfectly when it comes to deleting the
data from the main form where the fields are unbound, but on the subform it
doesnt delete the data, it automatically stores it to the table since the
subform fields are bound to tblExpenseDetails. How can I rectify this
problem. what code can i write behind this delete command button that will
clear the data from teh subform/tblexpensedetails. i hope this question
makes sense. any help will be appreciated.
thanks
salisha
 
Hi Salisha
Hopefully you are using a unique order number field to link the
expense and expense details tables.
If this is the case create two select queries first using the build
criteria Forms-Loaded Forms-tblExpenseDetails-Order Number and
Forms-Loaded Forms-tblExpense-Order Number
Check that you are selecting the records that you wish to delete and
if so then convert the queries to delete queries
Behind your delete button run the query to delete the expense detail
records first and then the expense record
A word of caution - you will end up with 'missing' order numbers
unless each time you do this you reset your order number field in
tblExpense. I would consider simply adding a 'cancelled' Yes/No field
instead to tblExpenseDetails and a 'Notes' field to tblExpense where
an explanation can be entered

Regards

Geoff
 
Back
Top