Adding a character in front of a field

  • Thread starter Thread starter Sunny Sethi
  • Start date Start date
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)
 
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.
 
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.
 
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
 
Back
Top