rs.find or rs.filter

B

Brent

trying to use rg.find as shown below:

checkit = RTrim(rs.fields("ERCOT_UNIT_ID")) & "_" & RTrim(rs.fields _
("timestamp")) & "_" & RTrim(rs.fields("SETTLEMENT")) & "_" &
nameofbook
spcs = 150 - Len(checkit)
checkit = checkit & "" & Space(spcs)
rg.movefirst
rg.Find = "PRIMARY_KEY=" & checkit

I know the error is on the rg.Find line and is a result of the variable
checkit. Checkit is a string and Primary_Key is in the database as a char of
150 characters, hence the addition of blank spaces to checkit. How do I get
around this error? It seems you cannot use variables with the Find method?
Thank you.

Brent
 
V

Vergel Adriano

Brent,

I assume rg is an ADO recordset object. try:

rg.Filter = "PRIMARY_KEY='" & checkit & "'"


Notice I added the single quote characters to enclose the checkit value.

Also, unless the values in PRIMARY_KEY column are right padded with spaces,
you won't need to pad checkit with spaces. you can also try:

rg.Filter = "TRIM(PRIMARY_KEY)=TRIM('" & checkit & "')"

but I think that would depend on the database you're connecting to.
 

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

Similar Threads

PRIMARY KEYS 1
Primary key search 1
Application Error 0
Error, don't know why 0
App. Error Excel 2003 0
Garbage in a string variable loaded from a field 2
Read A Text File 2
Proper case module help! 6

Top