how: combo box on focused requery not work

siamandm
BronzeLounger
Posts: 1226
Joined: 01 May 2016, 09:58

how: combo box on focused requery not work

Post by siamandm »

hello all

I have a combo box to show employee list on the data entry form and go to a specific employee when I select it,

when I add a new employee and then go to that combo box straight away the new employee not show on the list
what is that form.name ... do I have to specify it somewhere?
note: this code generated from macro

Code: Select all

Private Sub cboEmployee_GotFocus()
On Error GoTo cboEmployee_GotFocus_Err


    On Error Resume Next
    If (Screen.ActiveForm.Name = Form.Name) Then
        DoCmd.Requery Screen.ActiveControl.Name
    End If
cboEmployee_GotFocus_Exit:
    Exit Sub

cboEmployee_GotFocus_Err:
    MsgBox Error$
    Resume cboEmployee_GotFocus_Exit
End Sub

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: how: combo box on focused requery not work

Post by HansV »

Try simplifying the code to

Code: Select all

Private Sub cboEmployee_GotFocus()
    On Error Resume Next
    Me.Dirty = False
    DoCmd.Requery Me.cboEmployee
End Sub
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1226
Joined: 01 May 2016, 09:58

Re: how: combo box on focused requery not work

Post by siamandm »

working very well thank you very much