calculated default date

GAZZAT5

Board Regular
Joined
Feb 8, 2005
Messages
68
I have a loans table that contains the days, [days loaned], and weeks, [weeks loaned] loaned for as fields, and I want it to work out the return date from the date loaned, [date loaned] based on these values.

So the Default Value ofn the return by field would be
Code:
=DateAdd("ww",[weeks loaned],DateAdd("d",[days loaned],[date loaned]))

where [weeks loaned] and [days loaned] are both numbers with field size byte, and [date loaned] and [return by] are dates.

Yet when I try to save it, it comes up with the error:
[The database engine does not recognize either the field 'weeks loaned' in a validation expression, or the default value in the table 'loans'.

Many thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
You cant bind calculated fields to a table.
You should just create the info on the fly when you need it from the stored data.

HTH

Peter
 
Upvote 0
Ok.

So how would i go about it, would it be a vba script on the afterupdate on a form, or something else?

Cheers
 
Upvote 0
Ok so this would be a calculated field on a form based upon the date loaned, and the number of weeks and days loaned for.

Using the code from above, in the controlsource of a textbox, slightly edited, it still comes up with the #Name? error. Why is it going wrong?

Heres my code:
Code:
=DateAdd("ww",loans![Weeks loaned],DateAdd("d",loans![Days loaned],loans![Date loaned]))

Many thanks.
 
Upvote 0
Hi
Try removing the three loans! references in your formula. If the form is based on the table (or query) then it will find the 'Weeks loaned', 'Date loaned' and 'Days loaned' fields - provided you have spelt them correctly and they exist in the underlying table (or query). However, in kmy opinion it would be better to perform these calculations in a query and then base your form on that query.
HTH, Andrew :)
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top