Setfocus after Requery

  • Thread starter Thread starter hlam
  • Start date Start date
H

hlam

I received the following error message after an after update event of a
combo box on every change of this combo box. I need to set focus on the
subform so that user can input data right from there.

2110 microsoft access can't move the focus to the control Master Table
subform.

Here is the codes of this event:-

Private Sub txtClient_AfterUpdate()

On Error GoTo Err_Handler

'to retrieve data base on the combo box
Me.Master_Table_subform.Requery

'list box 1 and select the first row as default value base on combo box
Me.txtCat.Requery
Me.txtCat.Selected(0) = True
Me.txtCat.Value = Me.txtCat.Column(0)

'list box 2 base on the selection from list box 1
'user may have the chose to enter data manually or double click from
list box 2 to subform
Me.lstDesc.Requery

'this is the line that gives the error, but when run a second time it is
ok
Me.Master_Table_subform.SetFocus

With [Forms]![volume input].[Master Table subform].Form
.Recordset.AddNew
'this is the colume that I want to setfocus that users can enter
data
'from here if they decide not to double click the list box 2
.Code.SetFocus
End With

Exit Sub

Err_Handler:
MsgBox err.Number & " " & err.Description, vbCritical

End Sub

I am running on Access 2000. Thank you.
 
I found the solution finally. It is just a matter of the codes sequence
causing problem. After I moved all related codes for the subform to the
beginning everything works fine now.

Thank you for reading anyways,
 
Back
Top