PRIMARY KEYS

B

Brent

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??
 
B

Brent

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
 

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

rs.find or rs.filter 1
Primary key search 1
Application Error 0
Error, don't know why 0
App. Error Excel 2003 0
Securing primary key in an access form 2
Foreign Key <--> Primary Key Dilemma 0
Primary Key 1

Top