populating field

J

JY

Hello,
i would like to be able to automatically populate a field in a table from a
form

the fields are as follow:
FirstName
LastName
E-mail

i am able to concatenate the field in the form but i'm not sure how to
submit my result to the table.

the formula in the e-mail field in the form is
[FirstName] & "."& [LastName] & "@abc.com"

how do i submit this to the table
 
T

Tom van Stiphout

On Mon, 2 Nov 2009 19:36:05 -0800, JY <[email protected]>
wrote:

Well, one could argue that there is no need to store Email in a table,
since it is a calculated value, and an important relational design
rule says you should not store calculated fields. What if someone
changes his or her lastname? Will you not forget to also update the
email field?

If I did not convince you, you could proceed like this: in both the
FirstName_AfterUpdate and the LastName_AfterUpdate event write:
Me.myEmailControl = CalculateEmail()

Then write a function:
private function CalculateEmail() as string
CalculateEmail = Nz(Me.myFirstNameControl,"") & "." &
Nz(Me.myLastNameControl,"") & "@abc.com"
end function

-Tom.
Microsoft Access MVP
 
J

John W. Vinson

Hello,
i would like to be able to automatically populate a field in a table from a
form

the fields are as follow:
FirstName
LastName
E-mail

i am able to concatenate the field in the form but i'm not sure how to
submit my result to the table.

the formula in the e-mail field in the form is
[FirstName] & "."& [LastName] & "@abc.com"

how do i submit this to the table

In addition to the very valid problems Tom mentions, what if you happen to
have two employees who happen to have the same first and last name? A good
many year ago I once worked with Dr. Lawrence David Wise and his colleague,
Dr. Lawrence David Wise. Which one gets their name as their email?
 
J

JY

Thanks for your response but it doesn't seem to be working. i'm not sure what
i'm doing wrong. i new to Access and creating forms

In my form i added
Me.myEmailControl = CalculateEmail() in the after update in the [Event
Procedure] of FirstName & LastName field.

then i added
private function CalculateEmail() as string
CalculateEmail = Nz(Me.myFirstNameControl,"") & "." & Nz
Me.myLastNameControl,"") & "@abc.com"
end function

when i open my form and enter the firstName and the LastName in those the
e-mail field those not populate. i must have mist something.


Tom van Stiphout said:
Well, one could argue that there is no need to store Email in a table,
since it is a calculated value, and an important relational design
rule says you should not store calculated fields. What if someone
changes his or her lastname? Will you not forget to also update the
email field?

If I did not convince you, you could proceed like this: in both the
FirstName_AfterUpdate and the LastName_AfterUpdate event write:
Me.myEmailControl = CalculateEmail()

Then write a function:
private function CalculateEmail() as string
CalculateEmail = Nz(Me.myFirstNameControl,"") & "." &
Nz(Me.myLastNameControl,"") & "@abc.com"
end function

-Tom.
Microsoft Access MVP

Hello,
i would like to be able to automatically populate a field in a table from a
form

the fields are as follow:
FirstName
LastName
E-mail

i am able to concatenate the field in the form but i'm not sure how to
submit my result to the table.

the formula in the e-mail field in the form is
[FirstName] & "."& [LastName] & "@abc.com"

how do i submit this to the table
.
 

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