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

Works now, must be a constant....


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

"Brent" wrote:

I am trying to search a database for a primary key, and if it exists then I
will not upload the current file. I tried the code below, but it does not
seem to work, I think because of what I am trying to find. I notice that if
I do not include a check the program finds a duplicate primary key almost
instantly, what can I do to make the search as fast as possible? Thank you.

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 rg.fields("PRIMARY_KEY") = checkit

PRIMARY_KEY is a char(150), so it has blank spaces for wha is not used,
hence the addition of spaces. But at rg.Find I keep getting error "Arguments
are of the wrong type, are out of acceptable range, or are in conflict with
one another" Run-time error '3001'. Any suggestions??

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
Sort worksheet on multiple keys - Primary, secondary, tirterary, etc. Doug Mc New Users to Excel 12 October 22nd 09 02:18 AM
Generating a primary key Access::Student Excel Discussion (Misc queries) 7 July 1st 09 11:07 PM
(Primary) Key Column? Rebecca Excel Discussion (Misc queries) 5 September 21st 08 05:14 PM
Check for Primary Key BillyRogers Excel Programming 2 September 20th 06 06:06 PM
How to use Alt keys + symbol keys to invoke a macro? keithb Excel Programming 1 December 19th 05 08:54 PM


All times are GMT +1. The time now is 03:21 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"