Default value of one field in access to contents of another field

B

baden penrose

In Access 2003, I would like to set the default value of one table to be the
contents of another field in the same table
 
C

Craig Alexander Morrison

Why?

I am unclear what you are asking perhaps you could give examples of the
values that you are concerned with.

It is generally a very bad idea to have two fields with the same value
unless they represent different things in the real world, and are likely to
have different values over time. By that I mean that the contents of the two
fields will not always be the same.

When you say the default value of one table to be the contents of another
field - did you mean contents of one field to be that of the other?
Otherwise not sure what you mean.
 
D

Duane Hookom

In addition to Craig's good advice, you can't set a field's default in table
design to another field.
 
B

baden penrose

Thank you for your response. I'm sorry my question was not clear -- this is
the first time I have used this service.

I have a database of names and addresses and I want to create a field in
which the data is the name by which an individual should be addressed.
Typically, this is the same as the first name (which is contained in another
field) so usually the two fields will contain the same information. In
quite a few cases (nicknames and abbreviations, for example) the information
will be different. I want to arrange it so that in default of special input
the first name information fills the field in question but can be overwritten.
The reason why I want the information duplicated where appropriate is for
mail merge purposes -- only one merge field needed.
 
C

Craig Alexander Morrison

I get it, yes you will need to this in a form.

I have designed systems such as this; you want the correct first name to
appear in mailings; however have the informal/friendly name for other
purposes.

What you need to do, probably on the AfterUpdate event on the FirstName
field on the form, is set the SalutationName (or NickName) field to the same
value.

Doing this on the AfterUpdate event is acheived using Me!SalutationName =
Me!FirstName in the event procedure.

If you already have data that you wish to update use the following SQL edit
to suit your table and field names,

UPDATE BusinessContacts SET BusinessContacts.SalutationName =
BusinessContacts.FirstName;
 
D

Duane Hookom

I don't think you can accomplish this in a table. You can use the after
update event of a text box on a form to set the value of another text box:

If IsNull(Me.txtNickName) Then
Me.txtNickName = Me.txtFirstName
End If
 
B

baden penrose

Thanks. That's very helpful. What you advise is a bit beyond my present
level of skill, but I look forward to following your guidance and learning
how to do it
 
C

Craig Alexander Morrison

Of course if the guy changes his name you run the risk of him keeping the
same nick name, such as Serge Gainsborough changes his name to Robert
Pepper. Following your guidance - let me introduce to you the man you've
known for all those years - Serge Pepper. Sorry (vbg)
 
D

Duane Hookom

I suppose you could write code in the After update event that prompts the
user whether or not the nickname should be changed... I like to keep things
a bit simpler. Nicknames are supposed to stick for a life time. There are
still a few people who knew me in HS that still call me "animal".

--
Duane Hookom
MS Access MVP
--

Craig Alexander Morrison said:
Of course if the guy changes his name you run the risk of him keeping the
same nick name, such as Serge Gainsborough changes his name to Robert
Pepper. Following your guidance - let me introduce to you the man you've
known for all those years - Serge Pepper. Sorry (vbg)
 

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