Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2007

Tip: Looking for answers? Try searching our database.

Default value of a field on a form via an expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stone Cold Blues Boy - 05 May 2007 23:06 GMT
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".
strive4peace - 06 May 2007 05:07 GMT
="""" & [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
[quoted text clipped - 4 lines]
> 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".
Stone Cold Blues Boy - 07 May 2007 23:34 GMT
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] & """"
>
[quoted text clipped - 16 lines]
> > 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".
strive4peace - 08 May 2007 03:03 GMT
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.
[quoted text clipped - 21 lines]
>>> 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".
Stone Cold Blues Boy - 08 May 2007 03:23 GMT
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

> form BeforeInsert
> ---
[quoted text clipped - 52 lines]
> >>> 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".
strive4peace - 08 May 2007 06:13 GMT
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
[quoted text clipped - 59 lines]
>>>>> 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".
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.