I have a form that is used to enter/display industry levy payments.
It has a main section and two subforms, both of which are datasheets.
subform1 is based on a table and shows individual payment details.
subfrom2 is based on a query that calculates what the amount for the payments by lookign up a rate in a table and mutiplying this by the volume in the table subform 1 is based on.
The payment details are entered from "buyer generated" invoices. Subform2 simply displays what the payment amounts should be for checking purposes. This info is not stored anywhere.
the two subforms contain the same "AutoID" field.
This all works very nicely.
What I would really like to do is insert a check box in subform1 which when set to true will cause the payment amount from the matching "line" in subform2 to be copied across to subform1. This will save the users a lot of time.
I have tried two ways to do this.
An update query: -
Some Code: -
Both these methods work for the 1st record in subform1 is the first record in the datasheet. If the 2nd or subsequent record in the datasheet is selected, then the SQL or Code runs for the first record anyway.
How do I make the code/query recognise which record is selected in the subform1 datasheet?
NB: When I say the 1st record in the datasheet I mean the 1st displayed for a particular record on the main form, not the first record in the table subform1 is based on.
It has a main section and two subforms, both of which are datasheets.
subform1 is based on a table and shows individual payment details.
subfrom2 is based on a query that calculates what the amount for the payments by lookign up a rate in a table and mutiplying this by the volume in the table subform 1 is based on.
The payment details are entered from "buyer generated" invoices. Subform2 simply displays what the payment amounts should be for checking purposes. This info is not stored anywhere.
the two subforms contain the same "AutoID" field.
This all works very nicely.
What I would really like to do is insert a check box in subform1 which when set to true will cause the payment amount from the matching "line" in subform2 to be copied across to subform1. This will save the users a lot of time.
I have tried two ways to do this.
An update query: -
UPDATE tblLevyReceiptsDetail SET tblLevyReceiptsDetail.LevyPaid = Forms![Levy Receipts]!sbfRateCalc.Form!LevyDue
WHERE (((tblLevyReceiptsDetail.AutoID)=[Forms]![Levy Receipts]![sbfLevyReceiptsDetail].[Form]![AutoID]));
Some Code: -
Code:
Private Sub Correct_Click()
Dim RecNum As Integer
Dim PaidVal As Currency
RecNum = Forms![Levy Receipts]![subform1].Form![AutoID]
If Me![Correct] = True Then
Forms![MainForm]![subform2].Form![AutoID].SetFocus
DoCmd.FindRecord RecNum
PaidVal = Forms![MainForm]![subform2].Form![LevyDue]
Forms![MainForm]![subform1].Form![AutoID].SetFocus
DoCmd.FindRecord RecNum
Forms![Levy Receipts]![subform1].Form![LevyPaid] = PaidVal
Else
DoCmd.Beep
End If
End Sub
Both these methods work for the 1st record in subform1 is the first record in the datasheet. If the 2nd or subsequent record in the datasheet is selected, then the SQL or Code runs for the first record anyway.
How do I make the code/query recognise which record is selected in the subform1 datasheet?
NB: When I say the 1st record in the datasheet I mean the 1st displayed for a particular record on the main form, not the first record in the table subform1 is based on.