I have a weely report which contain of 2 text box. EmpNo.txt and Position.txt. I need to get the data from my access database when the form is loaded.

Before go to the weekly report form the system will check the loginID and password. The empno and position data is in the same table in Access. So, how I can write a code to tell system if the loginID and password is same as usertable then provide the Empno and position?

Please help!


I have write a code for the problem I'm facing, but it have some error,please help.

Private Sub Form_Load()

Dim Mydb As ADODB.Connection
Set Mydb = New ADODB.Connection
GetDB Mydb
Dim RS As ADODB.Recordset
Set RS = New ADODB.Recordset

Dim strName As String

strName = frmLogin.txtUserName.Text

RS.Open "Select EmpID from UserTable WHERE UserName =" & "'" & strName & "'", Mydb, adOpenKeyset

txtEmpNo.Text = RS!EmpID

This question has already been answered. Start a new discussion instead.