Debug Code

T

Tee See

This code runs as I expect down to the dotted line and then faults

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
 
B

Brian Bastl

What exactly are you trying to do? Are you wanting to find a record, and
then display it in the same form, or are you looking for a record which
you'd like to display in a different form? The form's After Update event is
not the place you want to code this either way.

If the former, making sure the Wizard button is depressed, add an unbound
combobox control to your form's header section. A dialogue will pop up.
You'll want to select the third option "find a record on my form ...."

If the latter, you would supply a Where condition to your DoCmd.OpenForm
statement.

Brian
 
G

Guest

Brian,

On a slightly different tangent, why is the After Update even not the place
to code this? This may help with me an issue I'm having in an After Update
event dealing with FindRecord.

Phesunov

Brian Bastl said:
What exactly are you trying to do? Are you wanting to find a record, and
then display it in the same form, or are you looking for a record which
you'd like to display in a different form? The form's After Update event is
not the place you want to code this either way.

If the former, making sure the Wizard button is depressed, add an unbound
combobox control to your form's header section. A dialogue will pop up.
You'll want to select the third option "find a record on my form ...."

If the latter, you would supply a Where condition to your DoCmd.OpenForm
statement.

Brian


Tee See said:
This code runs as I expect down to the dotted line and then faults

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


Top