Adding a character in front of a field

S

Sunny Sethi

Hi,

In a table I have 1 field(expense_id) which is a auto-
number field.

I want to create another field using the same value as the
(expense_id) BUT appending H in front of it.

e.g. expense_id - value = 1
refernce_if - value = H1

Thanks
Sunny
(e-mail address removed)
 
6

'69 Camaro

Hi, Sunny.

1.) Create a new field in your table, called reference_if.
2.) Create a new query and open the SQL View pane and write a SQL statement
such as the following:

UPDATE myTableName
SET reference_if = "H" & expense_id;

3.) Run the query.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 
D

Douglas J. Steele

NO! That's a violation of relational database theory: a field in a table
should not be totally derivable from other fields in the table.

Instead, create a query that has a computed field reference_if: "H" &
expense_id, then use the query wherever you would otherwise have used the
table.
 
6

'69 Camaro

Thanks, Doug, for that very important reminder! I forgot to mention it in
my earlier post, obviously. However, there are a few reasons to temporarily
(or permanently) violate the rules of relational database theory, such as
when the need arises to match table structures or to improve the performance
of queries. The bottom line is that one needs to be fully grounded in
proper relational database theory, and then know when relational database
rules can be bent.

Gunny
 

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

Top