Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default rs.find or rs.filter

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default rs.find or rs.filter

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.


--
Hope that helps.

Vergel Adriano


"Brent" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find blank with Advanced Filter CJ Excel Discussion (Misc queries) 2 December 16th 08 10:46 PM
Cannot find info entered when I use filter. HELP! Miss Cobb Excel Discussion (Misc queries) 1 October 20th 08 08:01 PM
Find, Filter and Paste Duplicates Appalachia Excel Discussion (Misc queries) 1 April 5th 08 01:43 AM
formula to find the filter criteria [email protected] Excel Worksheet Functions 12 December 30th 05 07:04 PM
"find" and "filter" working weirdly weiin t via OfficeKB.com Excel Discussion (Misc queries) 1 February 18th 05 11:03 PM


All times are GMT +1. The time now is 03:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"