need a variable for my recordset 
Author Message
 need a variable for my recordset

Hi there,

i'd like to use a recordset, with a variable in it, but i just can't seem to
get it to work. Because i'd like to filter out just the values from other
tables, that are from a specific customer. Who can help me out, please?

What i have got now is:

Dim klantid

klantid = rstklanten.Fields("klantcode").Value

rstfakturen.Open("Select * from faktuurgegevens where klantcode =" +
klantid, optiekdb, _

ADODB.CursorTypeEnum.adOpenDynamic, _

ADODB.LockTypeEnum.adLockOptimistic)



Tue, 26 Oct 2004 03:09:30 GMT  
 need a variable for my recordset

Quote:

> i'd like to use a recordset, with a variable in it, but i just can't seem to
> get it to work. Because i'd like to filter out just the values from other
> tables, that are from a specific customer. Who can help me out, please?

> What i have got now is:

> Dim klantid

> klantid = rstklanten.Fields("klantcode").Value

> rstfakturen.Open("Select * from faktuurgegevens where klantcode =" +
> klantid, optiekdb, _

Is "klantid" a text string, long integer, or what?  You may need to
surround its value with tick-marks or double-quotes.

Quote:
> ADODB.CursorTypeEnum.adOpenDynamic, _

> ADODB.LockTypeEnum.adLockOptimistic)

Either use the Call statement or lose the parentheses.  Unless you are
capturing a return value from a function or property, call subroutines
and methods either like this:

call foo.bar (larry, curly, moe)

...or like this:

foo.bar larry, curly, moe

--
Joe Foster <mailto:jlfoster%40znet.com>  "Regged" again? <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Tue, 26 Oct 2004 08:55:08 GMT  
 need a variable for my recordset

Quote:

> Hi there,

> i'd like to use a recordset, with a variable in it, but i just can't seem to
> get it to work. Because i'd like to filter out just the values from other
> tables, that are from a specific customer. Who can help me out, please?

> What i have got now is:

> Dim klantid

> klantid = rstklanten.Fields("klantcode").Value

> rstfakturen.Open("Select * from faktuurgegevens where klantcode =" +
> klantid, optiekdb, _

> ADODB.CursorTypeEnum.adOpenDynamic, _

> ADODB.LockTypeEnum.adLockOptimistic)

The correct way to do this is with a parameterized query with the
command object.

Use the command object and set the commandText property = "Select *
from faktuurgegevens where klantcode = ?"
and then use the Command.Pramaters.Append
Command.CreateParameter(....)

this will help reduce erros as well by validating the data type being
passed in.

-Jon

MCSD
www.commercecomponents.com



Wed, 27 Oct 2004 00:03:34 GMT  
 need a variable for my recordset
Jan -

I might not be understanding what you're trying to do, but it looks to me
like you want to filter an existing recordset to only show records from one
customer at a time. I'm assuming that rstklanten contains all the records,
and you'd like to filter that to the records of just one customer. If that's
not right, then you can probably ignore the rest of this message. Otherwise,
read on...

Take a look at the Filter property of the Recordset object. It will allow
you to limit a recordset to certain rows based on SQL-like syntax. For
example...

'Get the ID to filter on
klantid = rstklanten.Fields("klantcode").Value

'Restrict the recordset to that ID
rstklantern.Filter = "klantcode = " & klantid

'Do something here with the recordset...

'Remove the filter so that you have all the records again
rstklantern.Filter = ""

If this is what you're looking for and would like more information, post
back and I'll be happy to point you further along... Or, take a look at the
MSDN for the Filter property. If it's not what you're looking for, sorry for
wasting your time.

HTH.

- Rick


Quote:
> Hi there,

> i'd like to use a recordset, with a variable in it, but i just can't seem
to
> get it to work. Because i'd like to filter out just the values from other
> tables, that are from a specific customer. Who can help me out, please?

> What i have got now is:

> Dim klantid

> klantid = rstklanten.Fields("klantcode").Value

> rstfakturen.Open("Select * from faktuurgegevens where klantcode =" +
> klantid, optiekdb, _

> ADODB.CursorTypeEnum.adOpenDynamic, _

> ADODB.LockTypeEnum.adLockOptimistic)



Sat, 30 Oct 2004 02:06:17 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. need a variable in my recordset

2. need a variable in my recordset

3. ADO recordset: Object variable or with block variable not set

4. passing date variable in select statment of recordset variable

5. Object Variable in DAO Recordset

6. How: Use a variable in a recordset instance

7. Using variables for field names in recordset

8. Reference a variable not a Text in a recordset

9. variable names of columns in a recordset

10. use variable to access field of a recordset

11. Problem when I dcelare a variable as Recordset

12. Referencing a recordset item with a variable

 

 
Powered by phpBB® Forum Software