Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update record

Status
Not open for further replies.

Serenades

Programmer
Oct 3, 2001
21
0
0
SE
I want to update one column in one row, one record... the problem is that when i do my search i got more than one row matching my search, these rows are EXACT the same.

So when i do my update the column in all of these rows will be updated with a new value...

I only want the column updated in ONE row!

Some like this:
------------------------------------------------------------
sSQL = "SELECT * FROM TABLE WHERE COL1 = 'BAH' AND COL2 = 'BLAH'"

objRS.Open sSQL, objConnection ,0,2

objRS("COL1") = "TEST"
objRS.Update
------------------------------------------------------------

Say i got 4 rows in my search and when i then do my update all COL1 will change to "TEST"... not good...

PLEASE! I go mad!

-Robert-
 
Robert how 'bout

Code:
objRS.MoveLast
objRS.MoveFirst

objRS!COL1 = "TEST"
objRS.Update

End Sub

maybe if you specify which record you wish to work on. then it will only update the one

hth
Scoty ::)
"Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
Hmm, i cant .MoveLast, it gives me an error...

I use MSDASQL as my provider, could it have something to do with it?

-Robert-
 
I am really not fimiliar with MSDASQL, I use DSN

That is pretty strange that you can't move last what does your recordset open code look like. Maybe it has something to do with the way your are openning it.

Let me know
Scoty ::) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
Before you spend any more time on the problem you're on, you should solve the problem it's based on. You should never, ever end up with a database table that has rows that are exactly the same, with no difference anywhere, if you plan to access and edit those records. You need to introduce some unique field, even if it is an autocounter that you never use anywhere else. Then you can isolate one record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top