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 N number of Records

Status
Not open for further replies.

mjd1947

IS-IT--Management
May 29, 2013
10
0
0
US
Hi,

I want to have a command button that will prompt the user to update a specified number of records from the table. When clicked, a prompt will ask how many records and then update fields based on other controls. I have attempted this with the TOP function but cannot get the command to update only the TOP records returned.

Thanks in advance.
 
So there is a table with, let's say, 10 000 records. I click a button and I am asked: "How many records do you want to update?" I say: 15

Which 15 records out of 10 000 are being updated?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
It can be the first 15 records. Basically the 10,000 records would be a pool of open Product IDs and I want to select the first X amount to update. Does that make sense?
 
You may try something like:
[tt]
Update SomeTable
Set SomeField = 1234
Where PKField IN ([blue]Select TOP 15 PKField
From SomeTable
Where some condition to put the records in order[/blue])
[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
What Andy is trying to point out is that a table is an unordered relation, and the "first 15" mean nothing; like picking marbles out of a black sack with a blindfold on.

You must first put the set in some order before you can get the "first 15" with any meaning.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Got it. Thanks so much for the advice.
 
@mdj1947,

It's appropriate to thank a member for a [blue]Great post![/blue] using the link at the lower right-hand corner. This also help other members identify helpful post as they browse the threads posted in the forum.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top