Hi all... please help me with this code... i hv retrieved the id of the employee from the login n stored it as a lable in my form- logid but now with respect to that i want to get the employee name... please help very urgent!!

Dim rs As adodb.Recordset
Dim getname As String
getname = "SELECT E_name FROM Employee_Details WHERE E_ID ='" & logid.Caption & "'"
rs.Open getname, CN

logname.Caption = rs.Fields(0)

the error msg shown is "object variable or with block variable not set."
please help its very urgent!
thanx!
-smile4evr!

There are a few points that could cause error:
- change

Dim rs As adodb.Recordset

to

Dim rs As New adodb.Recordset

- make sure that CN is not nothing eg. you do have a valid connection object
- your query may return empty recordset. Haven't dealed with these for a long time but check that

rs.Fields(0)

is not nothing. I mean that rs is not nothing.

thnakx a lot!... it is solved...!
its working now!
tc!
n good day!

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