T
Tee See
Currently have a form "frmMainform" with subform "frmSubForm" where/when
there is no data in the subform I CLICK on a button to invoke a
"frmPopUpForm" to add info to the subform table which is bound. After close,
the requery statement takes place and requeries but returns the
"frmMainForm" and the related "frmSubform" to the first record of the
"frmMainForm".
How do I stay/return with/to the same record I was viewing when I invoked
the
"frmPopUpForm"?
I posted this once before but lost the answer. I have attempted to solve by
myself using logical (in my mind) programming but get stuck as follows.
The following code is in the AfterUpdate event of the popup form. I added
the primitive error handling just to stop the entire thing freeeeezing up.
The code runs as I would expect until the dotted line. The variable
strFindRec holde the "value" through the requery (I think) since the
debug.Print statement shows the correct value in the Immediate window of the
VBA editor.
Why does the FindRecord statement foul/fowl up?
Private Sub Form_AfterUpdate()
On Error GoTo Err_Hand:
Dim strFindRec As String
strFindRec = Me![SISItemCode].Value
Forms![frmMaterialMasterMain].Requery
Debug.Print strFindRec
Forms![frmMaterialMasterMain]![SISItemCode].SetFocus
-------------------------------------------------------------------------------------------
DoCmd.FindRecord strFindRec, acAnywhere, , acSearchAll, , acAll, False
Err_Hand:
DoCmd.GoToRecord , , acFirst
End Sub
there is no data in the subform I CLICK on a button to invoke a
"frmPopUpForm" to add info to the subform table which is bound. After close,
the requery statement takes place and requeries but returns the
"frmMainForm" and the related "frmSubform" to the first record of the
"frmMainForm".
How do I stay/return with/to the same record I was viewing when I invoked
the
"frmPopUpForm"?
I posted this once before but lost the answer. I have attempted to solve by
myself using logical (in my mind) programming but get stuck as follows.
The following code is in the AfterUpdate event of the popup form. I added
the primitive error handling just to stop the entire thing freeeeezing up.
The code runs as I would expect until the dotted line. The variable
strFindRec holde the "value" through the requery (I think) since the
debug.Print statement shows the correct value in the Immediate window of the
VBA editor.
Why does the FindRecord statement foul/fowl up?
Private Sub Form_AfterUpdate()
On Error GoTo Err_Hand:
Dim strFindRec As String
strFindRec = Me![SISItemCode].Value
Forms![frmMaterialMasterMain].Requery
Debug.Print strFindRec
Forms![frmMaterialMasterMain]![SISItemCode].SetFocus
-------------------------------------------------------------------------------------------
DoCmd.FindRecord strFindRec, acAnywhere, , acSearchAll, , acAll, False
Err_Hand:
DoCmd.GoToRecord , , acFirst
End Sub