Problem with default value in a form

  • Thread starter Thread starter Amit
  • Start date Start date
A

Amit

Hi,

I'm having a little trouble with entering a default value
in a form, and will appreciate any pointers.

I have a form to enter first and last names, email address
etc. I would like the default value of the email address
to be "(e-mail address removed)". The firstname and
lastname will be taken from the same form when entered by
the user. I've tried the following:

1. Added the following in the "Default Value" for the
email address field property:
=([frmStaffNew].[PersonFirstName] & "." & [frmStaffNew].
[PersonLastName] & "@server.com")

When I enter a new staff person, I see the following in
the email textbox: "(e-mail address removed)", but when I enter the
first and last names, the email address is not updated to
the default value.

2. Tried the same without the "[frmStaffNew]".

Thanks for any help.

-Amit
What am I missing?
 
The defualt value gets put in when the form opens so using the default will
not work for what you want. You should put your code into the afterupdate
event of the boxes for the name. Put into the code

Me.txtEmail = Me.txtFirst & "." & Me.txtLast & "@server.com"

Where txtEmail is the name of the field for the email, txtFirst is the box
for the first name, and txtLast is the box for the last name. I suggest
putting the code in both fields so that if you need to change either name
after the email address is generated, it will be updated.

Kelvin Lu
 
Thanks Kelvin. That worked!!

Can I also put the same code in the 'Before Update'
property of the email textbox?

-Amit
-----Original Message-----
The defualt value gets put in when the form opens so using the default will
not work for what you want. You should put your code into the afterupdate
event of the boxes for the name. Put into the code

Me.txtEmail = Me.txtFirst & "." & Me.txtLast & "@server.com"

Where txtEmail is the name of the field for the email, txtFirst is the box
for the first name, and txtLast is the box for the last name. I suggest
putting the code in both fields so that if you need to change either name
after the email address is generated, it will be updated.

Kelvin Lu

Amit said:
Hi,

I'm having a little trouble with entering a default value
in a form, and will appreciate any pointers.

I have a form to enter first and last names, email address
etc. I would like the default value of the email address
to be "(e-mail address removed)". The firstname and
lastname will be taken from the same form when entered by
the user. I've tried the following:

1. Added the following in the "Default Value" for the
email address field property:
=([frmStaffNew].[PersonFirstName] & "." & [frmStaffNew].
[PersonLastName] & "@server.com")

When I enter a new staff person, I see the following in
the email textbox: "(e-mail address removed)", but when I enter the
first and last names, the email address is not updated to
the default value.

2. Tried the same without the "[frmStaffNew]".

Thanks for any help.

-Amit
What am I missing?


.
 
Hi Kelvin,

One more thing. If I want the first name and last name to
be all lowercase in the email address field, but not in
the name fields, how would I do that?

I tried "lower(Me.firstname)" but that didn't work.
Thanks!

-Amit
-----Original Message-----
The defualt value gets put in when the form opens so using the default will
not work for what you want. You should put your code into the afterupdate
event of the boxes for the name. Put into the code

Me.txtEmail = Me.txtFirst & "." & Me.txtLast & "@server.com"

Where txtEmail is the name of the field for the email, txtFirst is the box
for the first name, and txtLast is the box for the last name. I suggest
putting the code in both fields so that if you need to change either name
after the email address is generated, it will be updated.

Kelvin Lu

Amit said:
Hi,

I'm having a little trouble with entering a default value
in a form, and will appreciate any pointers.

I have a form to enter first and last names, email address
etc. I would like the default value of the email address
to be "(e-mail address removed)". The firstname and
lastname will be taken from the same form when entered by
the user. I've tried the following:

1. Added the following in the "Default Value" for the
email address field property:
=([frmStaffNew].[PersonFirstName] & "." & [frmStaffNew].
[PersonLastName] & "@server.com")

When I enter a new staff person, I see the following in
the email textbox: "(e-mail address removed)", but when I enter the
first and last names, the email address is not updated to
the default value.

2. Tried the same without the "[frmStaffNew]".

Thanks for any help.

-Amit


.
 
You do not need to put the code into the email text box. That wouldn't
help. Access doesn't actually store the information typed into a box until
you hit enter or click outside the box, thats why you can hit the escape key
an cancel what you typed in. The beforeupdate event could be used to do a
validation check but if you try to change the value of the box, then the
program gets confused and will probably give you an error message. If you
want to change something that is typed in you should use the after update
event.

The correct function is LCASE not LOWER. LCASE(Mr.FirstName). Good luck.

Kelvin

Amit said:
Hi Kelvin,

One more thing. If I want the first name and last name to
be all lowercase in the email address field, but not in
the name fields, how would I do that?

I tried "lower(Me.firstname)" but that didn't work.
Thanks!

-Amit
-----Original Message-----
The defualt value gets put in when the form opens so using the default will
not work for what you want. You should put your code into the afterupdate
event of the boxes for the name. Put into the code

Me.txtEmail = Me.txtFirst & "." & Me.txtLast & "@server.com"

Where txtEmail is the name of the field for the email, txtFirst is the box
for the first name, and txtLast is the box for the last name. I suggest
putting the code in both fields so that if you need to change either name
after the email address is generated, it will be updated.

Kelvin Lu

Amit said:
Hi,

I'm having a little trouble with entering a default value
in a form, and will appreciate any pointers.

I have a form to enter first and last names, email address
etc. I would like the default value of the email address
to be "(e-mail address removed)". The firstname and
lastname will be taken from the same form when entered by
the user. I've tried the following:

1. Added the following in the "Default Value" for the
email address field property:
=([frmStaffNew].[PersonFirstName] & "." & [frmStaffNew].
[PersonLastName] & "@server.com")

When I enter a new staff person, I see the following in
the email textbox: "(e-mail address removed)", but when I enter the
first and last names, the email address is not updated to
the default value.

2. Tried the same without the "[frmStaffNew]".

Thanks for any help.

-Amit


.
 
Back
Top