dbTalk Databases Forums  

Question on Access database design

comp.databases.ms-access comp.databases.ms-access


Discuss Question on Access database design in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jeffrey Needle
 
Posts: n/a

Default Question on Access database design - 01-29-2011 , 07:44 AM






Hello. I'm using Access 2007 on a WinXP system. I'm stymied on how to
get a calculation to work properly.

I'm a book review editor, and I'm keeping track of books I've sent out
for review, etc. One field is titled "Date Book Received." I want to
create a column in the table titled "Date Review Due" which takes the
value in "Date Book Received" and adds 30 days to that date. I also
want to have a column titled "Days Out" that takes today's date and
subtracts the value in "Date Book Received."

Do I create this formula in the "Default Value" area? Using the
expression builder, I can't find a way of inserting field names.

Any help will be greatly appreciated.

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Question on Access database design - 01-29-2011 , 11:17 AM






Jeffrey Needle wrote:
Quote:
Hello. I'm using Access 2007 on a WinXP system. I'm stymied on how to
get a calculation to work properly.

I'm a book review editor, and I'm keeping track of books I've sent out
for review, etc. One field is titled "Date Book Received." I want to
create a column in the table titled "Date Review Due" which takes the
value in "Date Book Received" and adds 30 days to that date. I also
want to have a column titled "Days Out" that takes today's date and
subtracts the value in "Date Book Received."

Do I create this formula in the "Default Value" area? Using the
expression builder, I can't find a way of inserting field names.

Any help will be greatly appreciated.


Days Reviewed Example
In the control source of the textbox for the review day due in the
property sheet enter
=dateadd("d",30,Forms!YourFormName!YourBookReceive dTextboxName)
Substitute the "Your..." name with the real value


Days Out example
Public Function DaysOut() As Variant
Dim datRecvd as date
'substitute the "Your" values with the form and field names
datRecvd = Forms!YourFormName!YourReceivedFieldName
DaysOut = DateDiff("d",datRecvd,Date)
End Function

Then in your text box for your form's ControlSource property sheet/data
tab enter
=DaysOut()
and that will calculate the days out value.

I demo'd 2 examples. One uses a formula in the control source, the
other calls a function.

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Question on Access database design - 01-29-2011 , 12:03 PM



On 29/01/2011 17:17:22, Salad wrote:
Quote:
Jeffrey Needle wrote:
Hello. I'm using Access 2007 on a WinXP system. I'm stymied on how to
get a calculation to work properly.

I'm a book review editor, and I'm keeping track of books I've sent out
for review, etc. One field is titled "Date Book Received." I want to
create a column in the table titled "Date Review Due" which takes the
value in "Date Book Received" and adds 30 days to that date. I also
want to have a column titled "Days Out" that takes today's date and
subtracts the value in "Date Book Received."

Do I create this formula in the "Default Value" area? Using the
expression builder, I can't find a way of inserting field names.

Any help will be greatly appreciated.



Days Reviewed Example
In the control source of the textbox for the review day due in the
property sheet enter
=dateadd("d",30,Forms!YourFormName!YourBookReceive dTextboxName)
Substitute the "Your..." name with the real value


Days Out example
Public Function DaysOut() As Variant
Dim datRecvd as date
'substitute the "Your" values with the form and field names
datRecvd = Forms!YourFormName!YourReceivedFieldName
DaysOut = DateDiff("d",datRecvd,Date)
End Function

Then in your text box for your form's ControlSource property sheet/data
tab enter
=DaysOut()
and that will calculate the days out value.

I demo'd 2 examples. One uses a formula in the control source, the
other calls a function.

What worries me is that the OP says he wants to create a column in a TABLE.
Bad idea. Tables are only for storing data, virtually never for entering data
or holding calculated values.
As Salad says, the required fields should be shown in a form based on the
table.

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.