[AccessD] Updating Form Recordsource and Selecting Control

David Emerson newsgrps at dalyn.co.nz
Thu Feb 9 17:47:26 CST 2017


Hi Listers,

I have a form with an unbound control called txtWallpaperBarcode.  When text
is entered into the control and the after update event triggered then the
form's recordset is updated using the entered text as a filter as follows:

        Set rstTemp = basRunDataObject("dbo.spfrmWallpaperLookup '" &
Me!txtWallpaperBarcode & "'", adCmdText)
        If rstTemp.RecordCount <> 0 Then
            Set Me.Recordset = rstTemp
       End If

This all works fine.  Once the recordset is updated I would like the control
to get the focus again.  This is the part I am struggling with.

The control is the first in the tab order.  Next in tab order is an unbound
control (txtAfterBarcode) which has the following code in the Enter event:

DoCmd.GoToControl "txtWallpaperBarcode"

When the Update code is finished the second control doesn't get the focus.
I assume this is because the forms recordset is updated.  I have tried
forcing the move at the end of the Update code with this line:

    DoCmd.GoToControl "txtAfterBarcode"

But I get an error saying that I can't move the focus to the control
txtAfterBarcode.  It seems to be due to the Enter event wanting to move it
out again.

Any suggestions?

Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand







More information about the AccessD mailing list