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.

byusing

Dim rs As new adodb.Recordset

your problem is solved.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.