Find specific record

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Debug Code 2
Stay with Current Record 1
Cloning a record 2
search box to search all fields 0
Find Record 1
DoCmd.FindRecord error 3
Find Record Error 0
Find Record 0

Top