Automaticaly fill in a text box

C

Cameron Piper

All,

I have a form that I am working and would like to know if
I can accomplish what seems like a very simple task. The
forms data source is a table called "tblClient". "Client
ID" is the primary key in this table and I would like to
have access automaticaly put a value in the primary field
based on some other entry done by the user. Two of the
other fields being used are named "NameFirst"
and "NameLast." I would prefer to use the NameLast,
NameFirst as my ClientID. Is this a macro item, is this
a query item? I have tried numerous ways to figure this
out, but just can't seem to pull it off. I apologize for
my Newby status, but I am reading every day and trying to
learn. Will someone please point me in the right
direction. I appreciate all of your help in advance.

Cameron
(e-mail address removed)
 
D

Duane Hookom

I would recommend against this. How would you handle clients that change
their names? What happens if you have two or more Robert Smiths? I use an
autonumber primary key for every table that I create.

You can use code in the before update event of a form to update the primary
key. However, I think this is a really poor idea.
 
C

Cameron Piper

Duanne,

I appreciate greatly your imput and have reconsidered
using this is a way to store my data, I will be going
through and changing my ClientID field to an autonumber.

However, I do have one more question for you. The
database that I am working on contains thousands of
people how would you recommend handling a situation where
a user needs to lookup a person by their name but has no
way to know which number represents that person. Could
this be accomplished by a query and a record selector
combo box?

Cameron
 
I

Immanuel Sibero

Hi

As Duane said, dont do this. Is there any particular reason why you prefer
NameLast&NameFirst to be your primary key?
If you're thinking ahead that later on you may need the table to be sorted
this way or you may want do a search this way, then NameLast&NameFirst can
easily be calculated in a query. So you dont have to set up an additional
field in your table to combine them, and you certainly dont want to combine
them and make them primary key.

HTH
Immanuel Sibero
 
J

John Vinson

However, I do have one more question for you. The
database that I am working on contains thousands of
people how would you recommend handling a situation where
a user needs to lookup a person by their name but has no
way to know which number represents that person. Could
this be accomplished by a query and a record selector
combo box?

Absolutely. The user should never have to type in an autonumber value;
in general they should never even SEE an autonumber value! It should
be "under the hood" of the application.

Use a Form for data entry (not a table datasheet, on the same
principle); on that Form you can have a Combo Box which stores the
autonumber value into the numeric client ID field but which displays
the person's name, perhaps along with some other field that would
allow you to distinguish the Bob Smith who lives in Pasadena from the
Bob Smith in Altamont.
 

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