Return RecordSet

A

Albert D. Kallal

You got a number of problems where:

First, you sql has to be correct.

You got

Me![employeeID] =


Do you really have bizare field called me![Emplyeeid]? I kind of doubt it.
You likely have a field called EmployeedID

Further, you are using a constant of dbOpenDynSet

Just leave the constant out all to gether, or use dbOpenDynaset

so, I would suggest trying the following code:

dim strSql as string

Set Db = CurrentDb

strSql = "Select * from employee_info " & _
"where EmployeedId = " & me!EmployeeId

However, if EmplyeedId is a text/string type field, then you do have to
surround the above value with quotes (as you correlity had) , so we would
get:

strSql = "Select * from employee_info " & _
"where EmployeedId = '" & me!EmployeeId & "'"

Set rst = Db.OpenRecordset(strSql)
 
K

Kenneth Goodwin

Hi guys,
Can some one please tell me why this don't work.

I am trying to get some data from the table to check before update or save
as new

Dim bankRs As DAO.Recordset
Dim employeeRS, emptypeRS, rst As DAO.Recordset
Dim xemployeetype, empID As String


Set Db = CurrentDb
Set rst = Db.OpenRecordset("Select * from employee_info where
Me![employeeID] = '" & Me.employeeID & "'", dbOpenDynSet)

Kenneth
(e-mail address removed)
 
D

Dirk Goldgar

Kenneth Goodwin said:
Hi guys,
Can some one please tell me why this don't work.

I am trying to get some data from the table to check before update or
save as new

Dim bankRs As DAO.Recordset
Dim employeeRS, emptypeRS, rst As DAO.Recordset
Dim xemployeetype, empID As String


Set Db = CurrentDb
Set rst = Db.OpenRecordset("Select * from employee_info where
Me![employeeID] = '" & Me.employeeID & "'", dbOpenDynSet)

In addition to Albert's comments, which explain why you're getting an
error at the moment, you should be aware that your statements,
Dim employeeRS, emptypeRS, rst As DAO.Recordset
Dim xemployeetype, empID As String

actually declare employeeRS, emptypeRS, and xemployeetype as Variant,
not as Recordset or String. You have to include the "As {type}" with
each variable declared; e.g.,

Dim employeeRS As DAO.Recordset, emptypeRS As DAO.Recordset
Dim rst As DAO.Recordset
Dim xemployeetype As String, empID As String
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top