INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Is updating names in a table easier with a query or code?

Is updating names in a table easier with a query or code?

(OP)
I have a table that contains a field for office location and a field for a Computer Name
of a PC in each office. (BTW: this table does not have auto-number index field)

Location	ComputerName
Chicago Office	AS400 Server
Chicago Office	Office Dell PC
Chicago Office	Office Dell PC
Chicago Office	Sparc Station
Dallas Office	AS400 Server
Dallas Office	Office Dell PC
Dallas Office	Office Dell PC
Dallas Office	Office Dell PC
Dallas Office	Sparc Station
Memphis Office	AS400 Server-
Memphis Office	Office Dell PC
Memphis Office	Office Dell PC
Memphis Office	Office Dell PC
Memphis Office	Sparc Station
Seattle Office	AS400 Server
Seattle Office	Office Dell PC
Seattle Office	Office Dell PC
Seattle Office	Sparc Station 


I would like to give each computer a unique name by adding a sequencial
number behind it in the table:

Location	ComputerName
Chicago Office	AS400 Server-1
Chicago Office	Office Dell PC-1
Chicago Office	Office Dell PC-2
Chicago Office	Sparc Station-1
Dallas Office	AS400 Server-2
Dallas Office	Office Dell PC-3
Dallas Office	Office Dell PC-4
Dallas Office	Office Dell PC-5
Dallas Office	Sparc Station-2
Memphis Office	AS400 Server-3
Memphis Office	Office Dell PC-6
Memphis Office	Office Dell PC-7
Memphis Office	Office Dell PC-8
Memphis Office	Sparc Station-3
Seattle Office	AS400 Server-4
Seattle Office	Office Dell PC-10
Seattle Office	Office Dell PC-9
Seattle Office	Sparc Station-4 

Can this be easily done by a query or can it only be done within
an event procedure?


Thanks


RE: Is updating names in a table easier with a query or code?

You need to first add an auto number to the table. Then you can run a make table query to create a new table.

CODE

SELECT 
 A.autoID, 
 A.Location, 
 A.ComputerName, 
 (select count(*) from tblComputers as B where B.AutoID < A.autoID and A.ComputerName = b.computerName)+1 AS Rank,  A.computerName & " - " & [Rank] AS NewName 
 INTO newtblComputer
FROM tblComputers AS A; 
Replace your old table with the new table and change field names as needed.

RE: Is updating names in a table easier with a query or code?

(OP)
Thank you for an easy solution MajP!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close