Where to put code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to open a filtered recordset in the detail section of a report

I have this statement

rs.Open "select * from tbl_McareDX where Procedure = CPT", db,
adOpenDynamic, adLockOptimis

Procedure is a string variable set to the value of a field on the report
CPT is a field in the table I am opening
db is set as the connection
rs is set as the recordset

I am getting the following error

Arguments are of the wrong type, out of acceptable range, or in conflict
with each other

Can anybody help with this?

I have also tried putting the field value [Procedure Code] in place of the
procedure variable but I get the same error.

Also I am able to open the table if I remove the select statement and just
use the table name tbl_McareDX
 
Try
rs.Open "select * from tbl_McareDX where [CPT] = " & [Procedure], db,
adOpenDynamic, adLockOptimistic

The square brackets are optional, but often help you to remember what
you are doing when you come back to the code. The reference to the
local variable has to be unquoted - when passed to the Jet Engine, it
is replaced by the variable's contents.


I am trying to open a filtered recordset in the detail section of a report

I have this statement

rs.Open "select * from tbl_McareDX where Procedure = CPT", db,
adOpenDynamic, adLockOptimis

Procedure is a string variable set to the value of a field on the report
CPT is a field in the table I am opening
db is set as the connection
rs is set as the recordset

I am getting the following error

Arguments are of the wrong type, out of acceptable range, or in conflict
with each other

Can anybody help with this?

I have also tried putting the field value [Procedure Code] in place of the
procedure variable but I get the same error.

Also I am able to open the table if I remove the select statement and just
use the table name tbl_McareDX

Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
I am trying to open a filtered recordset in the detail section of a report

I have this statement

rs.Open "select * from tbl_McareDX where Procedure = CPT", db,
adOpenDynamic, adLockOptimis

Procedure is a string variable set to the value of a field on the report
CPT is a field in the table I am opening
db is set as the connection
rs is set as the recordset

I am getting the following error

Arguments are of the wrong type, out of acceptable range, or in conflict
with each other

Can anybody help with this?

I have also tried putting the field value [Procedure Code] in place of the
procedure variable but I get the same error.

Also I am able to open the table if I remove the select statement and just
use the table name tbl_McareDX

rs.Open "select * from tbl_McareDX where Procedure = 'CPT'", db,
adOpenDynamic, adLockOptimis

Procedure is a Text Datatype field, so you must enclose the criteria
value CPT within quotes. Because the quotes are already within quotes,
use single quotes.
 
Back
Top