A
Amit
Hi,
I have a form to enter data for a budget, and I have
a "refresh" button on the same form to update and display
running totals for the budget (budget total, invoice
total, fees, remaining amount).
When I click on the "Refresh" button, it takes me to a new
record instead of keeping me on the same record. I'm not
sure why this is happening and would appreciate any help
and explanation, or possibly general guidelines/code
behind a "refresh" button.
I open this form through a menu, using "DoCmd.OpenForm
stDocName, , , , acFormAdd" behind a button, and the
Allow Edits/Deletions/Additions and Data Entry properties
of the form are set to "Yes". There is a sub-form on the
form to enter invoice details.
The code behind the "refresh" button is:
===========================================================
Private Sub cmdRefresh_Click()
On Error GoTo Err_cmdRefresh_Click
saverecnum = Me.CurrentRecord
saverecnumsfrm = Me!sfrmInvoiceItem.Form.CurrentRecord
Me.Dirty = False
Me.Requery
DoCmd.GoToRecord , , acGoTo, saverecnum
Me!sfrmInvoiceItem.SetFocus
DoCmd.GoToRecord , , acGoTo, saverecnumsfrm
Me.InvoiceAmount = Me.txtRunningTotal
Exit_cmdRefresh_Click:
Exit Sub
Err_cmdRefresh_Click:
MsgBox Err.Description
Resume Exit_cmdRefresh_Click
End Sub
===========================================================
Thanks!
-Amit
I have a form to enter data for a budget, and I have
a "refresh" button on the same form to update and display
running totals for the budget (budget total, invoice
total, fees, remaining amount).
When I click on the "Refresh" button, it takes me to a new
record instead of keeping me on the same record. I'm not
sure why this is happening and would appreciate any help
and explanation, or possibly general guidelines/code
behind a "refresh" button.
I open this form through a menu, using "DoCmd.OpenForm
stDocName, , , , acFormAdd" behind a button, and the
Allow Edits/Deletions/Additions and Data Entry properties
of the form are set to "Yes". There is a sub-form on the
form to enter invoice details.
The code behind the "refresh" button is:
===========================================================
Private Sub cmdRefresh_Click()
On Error GoTo Err_cmdRefresh_Click
saverecnum = Me.CurrentRecord
saverecnumsfrm = Me!sfrmInvoiceItem.Form.CurrentRecord
Me.Dirty = False
Me.Requery
DoCmd.GoToRecord , , acGoTo, saverecnum
Me!sfrmInvoiceItem.SetFocus
DoCmd.GoToRecord , , acGoTo, saverecnumsfrm
Me.InvoiceAmount = Me.txtRunningTotal
Exit_cmdRefresh_Click:
Exit Sub
Err_cmdRefresh_Click:
MsgBox Err.Description
Resume Exit_cmdRefresh_Click
End Sub
===========================================================
Thanks!
-Amit