Default Value

G

Greg

Hello,
I would like to set the default value of a text box on a
form. I am opening the form with the docmd and the text
box name is [title]. Your help is greatly appreciated.
Thanks
Greg
 
G

Greg

Tina,
I tried this after the docmd.openform but it gives me an
error. Since I am using this form in several different
areas I do not want to put the default directly on the
form but in the code that opens the form.
Thanks
-----Original Message-----
try using the Load event of the form you're opening.

Me!Title.DefaultValue = "x"

hth


Greg said:
Hello,
I would like to set the default value of a text box on a
form. I am opening the form with the docmd and the text
box name is [title]. Your help is greatly appreciated.
Thanks
Greg


.
 
D

Douglas J. Steele

Actually, if you're trying to set the default value to a string, you need to
include extra quotes:

Me!Title.DefaultValue = """x"""

If it's a numeric value, you just need the one set of quotes:

Me!Title.DefaultValue = "1"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Greg said:
Tina,
I tried this after the docmd.openform but it gives me an
error. Since I am using this form in several different
areas I do not want to put the default directly on the
form but in the code that opens the form.
Thanks
-----Original Message-----
try using the Load event of the form you're opening.

Me!Title.DefaultValue = "x"

hth


Greg said:
Hello,
I would like to set the default value of a text box on a
form. I am opening the form with the docmd and the text
box name is [title]. Your help is greatly appreciated.
Thanks
Greg


.
 
T

tina

if you're referring to the control in code that's running on another form,
you can't use
Me!Title
instead you have to refer explicitly to the form, as
Forms!MyFormName!Title
and use the quotes correctly, as Doug posted.

hth


Greg said:
Tina,
I tried this after the docmd.openform but it gives me an
error. Since I am using this form in several different
areas I do not want to put the default directly on the
form but in the code that opens the form.
Thanks
-----Original Message-----
try using the Load event of the form you're opening.

Me!Title.DefaultValue = "x"

hth


Greg said:
Hello,
I would like to set the default value of a text box on a
form. I am opening the form with the docmd and the text
box name is [title]. Your help is greatly appreciated.
Thanks
Greg


.
 

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