Primary Key

T

TBird

I have a long primary key, and it's divided into several sub-units (like
a social security number). However, only the last digits are unique,
how can I limit my search in a query to just the last 4?
 
J

jmonty

Use the Right() function.
Look up the example in Help. You might also want to look
up the Left() and Mid() functions as well, just for
reference.
In your query add the field containing the key.
For our example here we'll call it:
Field1
Then change the field entry into an expression:
Right([Field1],4)
Access will automatically create the Alias:
Expr1: Right([Field1],4)
You can change the alias into anything you'd like.
This will be the column heading.
hope this is what you were looking for.


-----Original Message-----
I have a long primary key, and it's divided into several sub-units (like
a social security number). However, only the last digits are unique,
how can I limit my search in a query to just the last 4?



------------------------------------------------
 
D

Dirk Goldgar

TBird said:
Can anyone help here?

Did you see the reply posted by jmonty?

I have to say, though, that if only the last 4 digits are unique, you
probably should have just the last 4 digits as the primary key, not some
long string that ends in those digits. If the leading part of the
string is always the same, you can use a format or a calculated field to
display that invariant part prefixed to the true key value.
 

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