Adding data to a table in a subform

I

Italian Pete

Hi,
I have an loans form divided into two. In the first part of the form,
the user inputs the dates of the loan and the name of the loanee. In the
second part of the form, there is a subform containing a table where details
of kit loaned is input.

On clicking an "Add Kit" button, a child form opens where, via a series of
combo boxes, an item of kit can be selected. On the PARENT form, there is a
button which executes the following code to write a new record to the subform
table:

Private Sub cmdSelectKit_click()

'go to new record in table
Forms!frmBooking!sbfrmTempLoansTable.SetFocus
DoCmd.GoToRecord , , acNewRec

'write new values into the table from the childform "frmChooseKit"
Forms!frmBooking!sbfrmTempLoansTable!equipment_id =
Forms!frmChooseKit!CboNumber
Forms!frmBooking!sbfrmTempLoansTable!EquipmentType =
Forms!frmChooseKit!cboKitType
Forms!frmBooking!sbfrmTempLoansTable!RDFIDCode =
Forms!frmChooseKit!cboAvailableKit
Forms!frmBooking!sbfrmTempLoansTable!Number = Forms!frmChooseKit!CboNumber

End Sub

This piece of code works.

However, when I try to put this code into a button on the CHILD form, the
first part (going to the new record) doesn't work.

Can anyone shed some light onto why this might be?

Many thanks,

Pete
 

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