J
Joan
Hi,
I have a form that is opened with the OpenForm method without any WHERE
criteria argument. When I delete a record on a subform in the form, the
form then moves to the first record in the recordset. I would like to set a
control on the main form to the value of a control in the subform footer for
the original record. How do I get the form to show the original record
again so that I can set the value of the control on the main form? I've
tried the following code to no avail.
Private Sub cmdDeleteOthChrg_Click()
On Error GoTo Err_cmdDeleteOthChrg_Click
Dim Myrs As Object
Dim InvNum As Long
Dim iAns As Integer
InvNum = Forms!EditDeleteInvoice!txtInvoiceNumber
iAns = MsgBox("This will delete " & Me!cboChargeCode & ". OK?", vbYesNo)
If iAns = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
'It is at this point that the form moves to the first record of the
recordset when I don't want it to.
DoCmd.FindRecord InvNum
With Me.Parent
!txtDebit = ![InvoiceDetailsSubEdit]![ExtendedPriceSum]
.Recalc
End With
Exit_cmdDeleteOthChrg_Click:
Exit Sub
Err_cmdDeleteOthChrg_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteOthChrg_Click
End Sub
What am I doing wrong?
Joan
I have a form that is opened with the OpenForm method without any WHERE
criteria argument. When I delete a record on a subform in the form, the
form then moves to the first record in the recordset. I would like to set a
control on the main form to the value of a control in the subform footer for
the original record. How do I get the form to show the original record
again so that I can set the value of the control on the main form? I've
tried the following code to no avail.
Private Sub cmdDeleteOthChrg_Click()
On Error GoTo Err_cmdDeleteOthChrg_Click
Dim Myrs As Object
Dim InvNum As Long
Dim iAns As Integer
InvNum = Forms!EditDeleteInvoice!txtInvoiceNumber
iAns = MsgBox("This will delete " & Me!cboChargeCode & ". OK?", vbYesNo)
If iAns = vbYes Then
DoCmd.RunCommand acCmdDeleteRecord
End If
'It is at this point that the form moves to the first record of the
recordset when I don't want it to.
DoCmd.FindRecord InvNum
With Me.Parent
!txtDebit = ![InvoiceDetailsSubEdit]![ExtendedPriceSum]
.Recalc
End With
Exit_cmdDeleteOthChrg_Click:
Exit Sub
Err_cmdDeleteOthChrg_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteOthChrg_Click
End Sub
What am I doing wrong?
Joan