Here is the code. cmbOP is a combo box from where an employee is chosen.
Private Sub cmbOP_click()
Set rsGetTarget = New ADODB.Recordset
If cmbOP.Text <> "" Then
' rs.Open "SELECT * FROM tblEmployeeDetails WHERE Name='" & cmbOP.Text & "'", con, adOpenKeyset, adLockPessimistic
rs.MoveFirst
rs.Find "Name='" & cmbOP.Text & "'"
' rsGetTarget.Open "SELECT * FROM tblTargets where badge_no='" & rs!badge_no & "' AND set_date = #" & lblToday_Date.Caption & "#", con, adOpenKeyset, adLockPessimistic
rsGetTarget.Open "SELECT * FROM tblTargets where badge_no='" & rs!badge_no & "'", con, adOpenKeyset, adLockPessimistic
With rsGetTarget
If .RecordCount > 0 Then
txtGB.SetFocus
txtGB.Text = !GB
txtRest_of_Online.SetFocus
txtRest_of_Online.Text = !Rest_of_Online
txtEDHC_OGID.SetFocus
txtEDHC_OGID.Text = !EDHC_OGID
txtEDHC_PO_Exception.SetFocus
txtEDHC_PO_Exception.Text = !EDHC_PO_Exception
txtEDHC_B2B.SetFocus
txtEDHC_B2B.Text = !EDHC_B2B
txtARB_OGID.SetFocus
txtARB_OGID.Text = !ARB_OGID
txtARB_IPORT.SetFocus
txtARB_IPORT.Text = !ARB_IPORT
TXTARB_DOMS.SetFocus
TXTARB_DOMS.Text = !ARB_DOMS
txtOP_QC.SetFocus
txtOP_QC.Text = !OP_QC
Else
txtGB.SetFocus
txtGB.Text = ""
txtRest_of_Online.SetFocus
txtRest_of_Online.Text = ""
txtEDHC_OGID.SetFocus
txtEDHC_OGID.Text = ""
txtEDHC_PO_Exception.SetFocus
txtEDHC_PO_Exception.Text = ""
txtEDHC_B2B.SetFocus
txtEDHC_B2B.Text = ""
txtARB_OGID.SetFocus
txtARB_OGID.Text = ""
txtARB_IPORT.SetFocus
txtARB_IPORT.Text = ""
TXTARB_DOMS.SetFocus
TXTARB_DOMS.Text = ""
txtOP_QC.SetFocus
txtOP_QC.Text = ""
End If
End With
End If