Default value of a field on a form via an expression

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am attempting to assign a default value to a field on a form by using the
following expression: =[Forms]![FormName]![FormField]. This expression is
designed to return the values: A, B, C, D, E, or F depending on the active
field on another form from which it is getting this information. The problem
is that it returns only the letter and as we all know text must be surrounded
by quotation marks to be utilized as a default value. I have tried
concantinating the quotation marks to the expression but failed. How can I
have my expression return a value of "A", "B", "C", "D", "E", or "F".
 
="""" & [Forms]![FormName]![FormField] & """"

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
I tried that and for some reason, it did not work. I'll try again to ensure
that I did not make a type O.

Thank you for your reply!!

strive4peace said:
="""" & [Forms]![FormName]![FormField] & """"

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I am attempting to assign a default value to a field on a form by using the
following expression: =[Forms]![FormName]![FormField]. This expression is
designed to return the values: A, B, C, D, E, or F depending on the active
field on another form from which it is getting this information. The problem
is that it returns only the letter and as we all know text must be surrounded
by quotation marks to be utilized as a default value. I have tried
concantinating the quotation marks to the expression but failed. How can I
have my expression return a value of "A", "B", "C", "D", "E", or "F".
 
form BeforeInsert
---


Hi Stone Cold (what is your name?)

another option is to set up the form BeforeInsert event to fill it in...

'~~~~~~~~~~~~~~~~~~~~~~~~
if isnull([Forms]![FormName]![FormField]) then
msgbox "Record cannot be added -- you must have a current record on
SOME FORMNAME",,"Cannot add record"
cancel = true
exit sub
end if

me.controlname = [Forms]![FormName]![FormField]

'~~~~~~~~~~~~~~~~~~~~~~~~

what is the Data Type for the underlying field for FormField?


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I tried that and for some reason, it did not work. I'll try again to ensure
that I did not make a type O.

Thank you for your reply!!

strive4peace said:
="""" & [Forms]![FormName]![FormField] & """"

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I am attempting to assign a default value to a field on a form by using the
following expression: =[Forms]![FormName]![FormField]. This expression is
designed to return the values: A, B, C, D, E, or F depending on the active
field on another form from which it is getting this information. The problem
is that it returns only the letter and as we all know text must be surrounded
by quotation marks to be utilized as a default value. I have tried
concantinating the quotation marks to the expression but failed. How can I
have my expression return a value of "A", "B", "C", "D", "E", or "F".
 
That (before insert) is a great solution that never occured to me! Thank you
very much!! The underlying data type is text which is why I need the
quotation marks around the letter for the default value property.

Thanks much,
SCBBoy

strive4peace said:
form BeforeInsert
---


Hi Stone Cold (what is your name?)

another option is to set up the form BeforeInsert event to fill it in...

'~~~~~~~~~~~~~~~~~~~~~~~~
if isnull([Forms]![FormName]![FormField]) then
msgbox "Record cannot be added -- you must have a current record on
SOME FORMNAME",,"Cannot add record"
cancel = true
exit sub
end if

me.controlname = [Forms]![FormName]![FormField]

'~~~~~~~~~~~~~~~~~~~~~~~~

what is the Data Type for the underlying field for FormField?


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I tried that and for some reason, it did not work. I'll try again to ensure
that I did not make a type O.

Thank you for your reply!!

strive4peace said:
="""" & [Forms]![FormName]![FormField] & """"

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Stone Cold Blues Boy wrote:
I am attempting to assign a default value to a field on a form by using the
following expression: =[Forms]![FormName]![FormField]. This expression is
designed to return the values: A, B, C, D, E, or F depending on the active
field on another form from which it is getting this information. The problem
is that it returns only the letter and as we all know text must be surrounded
by quotation marks to be utilized as a default value. I have tried
concantinating the quotation marks to the expression but failed. How can I
have my expression return a value of "A", "B", "C", "D", "E", or "F".
 
you're welcome ;) happy to help


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


That (before insert) is a great solution that never occured to me! Thank you
very much!! The underlying data type is text which is why I need the
quotation marks around the letter for the default value property.

Thanks much,
SCBBoy

strive4peace said:
form BeforeInsert
---


Hi Stone Cold (what is your name?)

another option is to set up the form BeforeInsert event to fill it in...

'~~~~~~~~~~~~~~~~~~~~~~~~
if isnull([Forms]![FormName]![FormField]) then
msgbox "Record cannot be added -- you must have a current record on
SOME FORMNAME",,"Cannot add record"
cancel = true
exit sub
end if

me.controlname = [Forms]![FormName]![FormField]

'~~~~~~~~~~~~~~~~~~~~~~~~

what is the Data Type for the underlying field for FormField?


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I tried that and for some reason, it did not work. I'll try again to ensure
that I did not make a type O.

Thank you for your reply!!

:

="""" & [Forms]![FormName]![FormField] & """"

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Stone Cold Blues Boy wrote:
I am attempting to assign a default value to a field on a form by using the
following expression: =[Forms]![FormName]![FormField]. This expression is
designed to return the values: A, B, C, D, E, or F depending on the active
field on another form from which it is getting this information. The problem
is that it returns only the letter and as we all know text must be surrounded
by quotation marks to be utilized as a default value. I have tried
concantinating the quotation marks to the expression but failed. How can I
have my expression return a value of "A", "B", "C", "D", "E", or "F".
 

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

Back
Top