RIGHT function question

P

Phil

Hello,

I have a table (Main_Data) containing a string field (PID) that has 9
characters, with a sample value being 450895624. I have created a new field
(PID-4) that I only want the last 4 characters to show in, so the new field
would have the value: 5624 in it.

I believe this is a RIGHT function question, but am not sure. I thing that
the function needs to something like: RIGHT (PID,4), but don't know where to
go from there.

Also, if I wanted to do this in a select query, if I put "PID-4:" in the
'Field' box, what then would I put following the colon?


TIA!

Phil
 
G

geebee

hi,

That would be...

SELECT tbl_name.column1, Right([PID],4) AS new_columnname
FROM tbl_name;

geebee
 
D

Douglas J. Steele

Don't use the minus sign in the field name: Access is going to assume you're
trying to do subtraction. Try renaming it PID_Last4, or something like that.
 
J

John Vinson

Hello,

I have a table (Main_Data) containing a string field (PID) that has 9
characters, with a sample value being 450895624. I have created a new field
(PID-4) that I only want the last 4 characters to show in, so the new field
would have the value: 5624 in it.

I believe this is a RIGHT function question, but am not sure. I thing that
the function needs to something like: RIGHT (PID,4), but don't know where to
go from there.

You cannot, and should not, do this in a Table. The table should not
contain redundant data like this - just calculate it as needed.
Also, if I wanted to do this in a select query, if I put "PID-4:" in the
'Field' box, what then would I put following the colon?

As suggested, DON'T use the - character in the fieldname. Try

Pid_4: Right([PID], 4)

in a vacant Field cell in a query. You can set the text of the form or
report Label for this field to PID-4 or whatever you wish; the users
should not be seeing the query datasheet in any case, so the fieldname
isn't going to be exposed anyway.

John W. Vinson[MVP]
 

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