Default Value

  • Thread starter Thread starter Greg
  • Start date Start date
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
 
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


.
 
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


.
 
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


.
 
Back
Top