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 / Database Design / January 2004

Tip: Looking for answers? Try searching our database.

Default Value of a Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Volz - 05 Jan 2004 16:36 GMT
To All on MSDN VB Discussion Forum:

Is it possible to make the default value of a field equal
to the value of another field or fields of the same record
in the current table?  If so, where would this information
be placed in the table design and what would the syntax be
to accomplish this task?  Any help or hints on this topic
would be greatly appreciated.  Thanks in advance.
Tim Ferguson - 05 Jan 2004 18:21 GMT
> To All on MSDN VB Discussion Forum:
>
> Is it possible to make the default value of a field equal
> to the value of another field or fields of the same record
> in the current table?  

No: at the time that the DefaultValue is being assigned, there are no other
values in any other fields (it's a new record, geddit?), so those values
cannot be used. The DefaultValue can only see constants and a few database
functions like DATE() and so on.

> If so, where would this information
> be placed in the table design and what would the syntax be
> to accomplish this task?  Any help or hints on this topic
> would be greatly appreciated.  

Depending what you want to achieve, there are various Form events that can
be used to write helpful stuff into the textboxes. The Form_BeforeUpdate or
Control_LostFocus are usually the most helpful ones.

Bear in mind that often this question is asked in order to create a
"calculated field" but that is always a bad thing to do.

Hope that helps

Tim F
John Vinson - 05 Jan 2004 19:00 GMT
>To All on MSDN VB Discussion Forum:
>
>Is it possible to make the default value of a field equal
>to the value of another field or fields of the same record
>in the current table?  

No. Defaults cannot refer to any other field; to do so would violate
third normal form. In addition, default values are applied the instant
a new record is created - the value of the other fields is unknown.

>If so, where would this information
>be placed in the table design and what would the syntax be
>to accomplish this task?  Any help or hints on this topic
>would be greatly appreciated.  Thanks in advance.

If you need to do this, you'll need to use VBA code in a Form that
you're using for data entry, perhaps in the AfterUpdate events of the
field or fields which define the default.

                 John W. Vinson[MVP]    
   Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
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



©2008 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.