Hi,
I am having a problem setting up a code that copy data from other forms into each single line into one datasheet subform.
What I managed to do was copy an individual parts of code into just one row in a form.
What I want to is how to compile that code that will make all the steps at once, something like that:
Make first point (1a, 1b) in first row
then go to next row and do 2a, 2b, 2c
and finally got to to next (third row)
and do 3a, 3b, 3c
Since I am more of a beginner in VBA I would be very happy for any idea or if you write the right code for me.
Thank you!
I am having a problem setting up a code that copy data from other forms into each single line into one datasheet subform.
What I managed to do was copy an individual parts of code into just one row in a form.
What I want to is how to compile that code that will make all the steps at once, something like that:
Make first point (1a, 1b) in first row
then go to next row and do 2a, 2b, 2c
and finally got to to next (third row)
and do 3a, 3b, 3c
Since I am more of a beginner in VBA I would be very happy for any idea or if you write the right code for me.
Thank you!
Code:
Private Sub PostVAT20_Click()
'Copy (Post) from VAT Form to Sub Form
'FIRST ROW:
'1a) First set focus to (first) New record in subform
Forms!EntryHead!GeneralLedger.SetFocus
DoCmd.GoToRecord , , acNewRec
'1b) Copy from Main Form to first row Record in a subform:
Forms!EntryHead.GeneralLedger.Form.Account = Forms!EntryHead.Account
Forms!EntryHead.GeneralLedger.Form.CustCode = Forms!EntryHead.CustCode
Forms!EntryHead.GeneralLedger.Form.Refer = Forms!EntryHead.Refer
Forms!EntryHead.GeneralLedger.Form.Debit = Forms!EntryHead.Debit
Forms!EntryHead.GeneralLedger.Form.Credit = Forms!EntryHead.Credit
Forms!EntryHead.GeneralLedger.Form.Narration = Forms!EntryHead.Narration
'SECOND ROW:
'2a) Then set focus to the NEXT (second) record Record in a subform
Forms!EntryHead!GeneralLedger.SetFocus
DoCmd.GoToRecord , , acNewRec
'2b) Copy from Main Form to that (second) row Record in a subform:
Forms!EntryHead.GeneralLedger.Form.CustCode = Forms!EntryHead.CustCode
Forms!EntryHead.GeneralLedger.Form.Refer = Forms!EntryHead.Refer
Forms!EntryHead.GeneralLedger.Form.Narration = Forms!EntryHead.Narration
'2c) Copy from VAT Form to that (second) row Record in a subform -NET Value:
Forms!EntryHead.GeneralLedger.Form.Account = Forms!VAT.ContraAccount
Forms!EntryHead.GeneralLedger.Form.Debit = Forms!VAT.NetValue20
'THIRD ROW:
'3a) Then set focus to the NEXT (third) record Record in a subform
Forms!EntryHead!GeneralLedger.SetFocus
DoCmd.GoToRecord , , acNewRec
'3b) Copy from Main Form to that (third) row Record in a subform:
Forms!EntryHead.GeneralLedger.Form.CustCode = Forms!EntryHead.CustCode
Forms!EntryHead.GeneralLedger.Form.Refer = Forms!EntryHead.Refer
Forms!EntryHead.GeneralLedger.Form.Narration = Forms!EntryHead.Narration
'3c) Copy from VAT Form to (third) row Record in a subform -VAT Value:
Forms!EntryHead.GeneralLedger.Form.Account = Forms!VAT.VATAccount20
Forms!EntryHead.GeneralLedger.Form.Debit = Forms!VAT.VAT20
End Sub