PC Review


Reply
Thread Tools Rate Thread

default table values

 
 
=?Utf-8?B?c2hvcnRfc3dlZXQ=?=
Guest
Posts: n/a
 
      28th Feb 2006
In a table how do I get the values of one feild to show in another feild?
example:
feild 1 named: Request No
feild 2 named: Serial No

I need the value of Request No to be =Year(Now()) & "-" & the value of
Serial No
 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      28th Feb 2006
Don't do it that way. You would be introducing redundancy which leaves the
door open to update anomalies. Store the date/time value when each row is
inserted into the table by having a column, DateTimeEntered say, with its
Default Value property set to Now() in table design. Don't have a Request No
column in the table but compute it in a query or in a computed control in a
form whenever required with:

[Serial No] & "-" & Year([DateTimeEntered]

Even though you don't need the full date time value in the DateTimeEntered
for this I'd nevertheless use the Now() function as the default. You might
well find it will come in extremely useful in the future to have a set of
unique values which determines not only when but the order in which rows
where inserted, something for which an autonumber column cannot be fully
relied on. Users never need see the DateTimeEntered column, it will just
quietly get on with its job in the background.

Ken Sheridan
Stafford, England

"short_sweet" wrote:

> In a table how do I get the values of one feild to show in another feild?
> example:
> feild 1 named: Request No
> feild 2 named: Serial No
>
> I need the value of Request No to be =Year(Now()) & "-" & the value of
> Serial No

 
Reply With Quote
 
=?Utf-8?B?T2Zlcg==?=
Guest
Posts: n/a
 
      28th Feb 2006
Create it in a query

Select [Serial No] , Year(Now()) & "-" & [Serial No] As [Request No] From
TableName

Ot in a field in the query it will look like
Request No:Year(Now()) & "-" & [Serial No]

--
\\// Live Long and Prosper \\//
BS"D


"short_sweet" wrote:

> In a table how do I get the values of one feild to show in another feild?
> example:
> feild 1 named: Request No
> feild 2 named: Serial No
>
> I need the value of Request No to be =Year(Now()) & "-" & the value of
> Serial No

 
Reply With Quote
 
=?Utf-8?B?c2hvcnRfc3dlZXQ=?=
Guest
Posts: n/a
 
      28th Feb 2006
ok, let me try this again, maybe I did not clarify what I needed.

1. no date is entered in either feild. It is added in the default value of
Request No feild. (ie. Year(Now()) & "-" & the value of Serial No

2. The value of Serial No is supposed to be incremented by one with each new
entry (which desn't work either) i.e start incrementing number at 300 and add
one for each new entry.

can get it to work in a form, but does not save value in table?

"Ken Sheridan" wrote:

> Don't do it that way. You would be introducing redundancy which leaves the
> door open to update anomalies. Store the date/time value when each row is
> inserted into the table by having a column, DateTimeEntered say, with its
> Default Value property set to Now() in table design. Don't have a Request No
> column in the table but compute it in a query or in a computed control in a
> form whenever required with:
>
> [Serial No] & "-" & Year([DateTimeEntered]
>
> Even though you don't need the full date time value in the DateTimeEntered
> for this I'd nevertheless use the Now() function as the default. You might
> well find it will come in extremely useful in the future to have a set of
> unique values which determines not only when but the order in which rows
> where inserted, something for which an autonumber column cannot be fully
> relied on. Users never need see the DateTimeEntered column, it will just
> quietly get on with its job in the background.
>
> Ken Sheridan
> Stafford, England
>
> "short_sweet" wrote:
>
> > In a table how do I get the values of one feild to show in another feild?
> > example:
> > feild 1 named: Request No
> > feild 2 named: Serial No
> >
> > I need the value of Request No to be =Year(Now()) & "-" & the value of
> > Serial No

 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      1st Mar 2006
You misunderstand the main point at issue here. By having both the Serial No
ands Request No columns in a table you are introducing redundancy because
part of the latter is determined by the former. The elimination of
redundancy is achieved by normalizing tables. The correct way to achieve
what you want is as I described in my last post and have two columns, one
with the date/time when the row was inserted into the table and one with the
sequential serial numbers. There is now no redundancy and therefore no
possibility of update anomalies. The Request No should not be stored but
computed by concatenating the values of the other two columns, inserting the
dash between them. This can be done in queries , on forms or in reports.

How you insert the sequential values for the Serial Number column depends on
whether the data base is in a single user or multi user environment. Both
are done in the data entry form, however. In a single user environment there
can be no conflicts between users inserting a row simultaneously so its very
easy to insert the next number in the form’s BeforeInsert event procedure by
using the DMax function to get the highest existing number , to which 1 is
then added e.g.


Me.[Serial No] = DMax("[Serial No]", "[Your table]") + 1

In a multi user environment in a network this could result in a conflict
with two users getting the same number. One way to avoid this is to store
the latest number in an external database on the server, which is opened
exclusively in code to get the next number. You’ll find a demo of this at
the following link:

http://community.netscape.com/n/pfx/...g=ws-msdevapps

Ken Sheridan
Stafford, England

"short_sweet" wrote:

> ok, let me try this again, maybe I did not clarify what I needed.
>
> 1. no date is entered in either feild. It is added in the default value of
> Request No feild. (ie. Year(Now()) & "-" & the value of Serial No
>
> 2. The value of Serial No is supposed to be incremented by one with each new
> entry (which desn't work either) i.e start incrementing number at 300 and add
> one for each new entry.
>
> can get it to work in a form, but does not save value in table?
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Table fields:- Setting default values to be based on other field values Rob W Microsoft Access 3 20th Feb 2008 08:51 PM
How to get default values from a table charles.kendricks@charter.net Microsoft Access 3 16th May 2007 07:13 AM
Default values from one table, entered values in another =?Utf-8?B?bGFzZXIwMjkxMA==?= Microsoft Access Forms 2 21st Jun 2005 10:01 PM
Default values in a table. Jason B Microsoft Access Database Table Design 1 1st Jul 2004 12:25 PM
Table Default Values Michael Volz Microsoft Access Forms 2 31st Jul 2003 03:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:42 AM.