adding field to a field in a table

crujazz

Registered User.
Local time
Today, 07:49
Joined
Jun 15, 2009
Messages
12
Hello everyone,

I have a table named tblGases, with a primairy-key and a 2 textfields.
What i like to do is to let the primairy-key appears in the first textfield.

Example:

idGasID (Autonumber)
txtGas (Text) (Default Value: "A-")
txtLocation (Text)

idGasID = 1......999

txtGas should look like: A-001.....A-999

My question: is this possible and if so how?

Thanks in advance
 
Why bother with the field in the table. You can recreate it instantly in a query for reports and forms with an expression. Will you never exceed 999 records?

"A-" & Right([tblgasses].[idGasID]+1000,3)
 
As Galaxiom said - you do this using a concatenated field in a query and you do not store it in the table. However, adding 1000 is not a good way to do it as you will not get 001 but it would be 1001.

In the query you can use:

MyNewFieldName:[txtGas] & Format([idGasID], "000")
 
Right([tblgasses].[idGasID]+1000,3) does work.

This expression returns the last three characters from 1000 plus the number in the field. Hence a single digit (shown as #) becomes 100# by adding 1000 then 00# with the Right function.

The Format function shown by SOS is more conventional. I just happened to come across the Right technique before I discovered the Format syntax so i use it sometimes.
 

Users who are viewing this thread

Back
Top Bottom