Hello everyone. I need help troubleshooting a query error. There is a form where if a user selects an Employee Id from a Combobox, the Label Below automatically displays the Employee Name.
Here is the query,
But, Due to some reasons, It's not working.Code:rs.Open "SELECT tblEmp.EM_ID, tblEmp.NAME FROM tblEmp where tblEmp.EM_ID = " & Me.cboEmpId.Text & " ;", cn, adOpenKeyset, adLockPessimistic
Codes,
Thanks in advance!Code:Private Sub cboEmpId_Change() If Me.cboEmpId.Text = vbNullString Then Exit Sub If rs.State = adStateOpen Then rs.Close rs.Open "SELECT tblEmp.EM_ID, tblEmp.NAME FROM tblEmp where tblEmp.EM_ID = " & Me.cboEmpId.Text & " ;", cn, adOpenKeyset, adLockPessimistic Do While rs.EOF = False Me.lblName.Caption = rs.Fields("NAME") rs.MoveNext Loop Exit Sub Set rs = Nothing End Sub




Reply With Quote
