[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Set Default Date in a table.

Posted on 2006-11-24
6
Medium Priority
?
253 Views
Last Modified: 2008-03-10
I am making a Database where I want to set the default date in the "DueDateS1" field to be 30 days from the "Date" field.
"Date" = Entered by data entry in table or Form
"DueDateS1" = To automatically calculate off of the "Date" entered.

I tried to use the DateAdd("d", +30, <<date>>) function and I am not sure what goes in the <<date>>.  I've tried using both "Date" and "DueDateS1"

I am pretty new to writing this type of code so any help would greatly appreciated.
0
Comment
Question by:rhedges
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 200 total points
ID: 18011178
Hi rhedges,

You cannot do this in a table design.
If you use a form then you can do what you require although it requires a ine of code to do so as below.

It is a bad idea to call a field Date because Date is a reserved word in Access.  Use a more descriptive fieldname.

The code you want goes in the Afterupdate event procedure of the first date field (which I shall call MyDate).

me.DueDateS1 = me.Mydate + 30

Note that any time the user changes the value in MyDate the DueDateS1 will be recalculated.

Pete
0
 
LVL 1

Expert Comment

by:Metroid
ID: 18011181
Hey rhedges,

To do this all you need to do is add the proper interval and field for the date (ie. DateAdd("d",30,[table field that contains date]).

Hope this helps.
0
 
LVL 1

Expert Comment

by:Metroid
ID: 18011186
RHEDGES,

Pete is correct in that you can't do this in a page design.  I would suggest you do this in a query. I would test it out by just doing a simple query using the date you want to modify.  Basically, DateAdd("d",30,[field with date]).
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 18

Expert Comment

by:p912s
ID: 18011660
As mentioned above you should change the name of your date field to MyDate or EntryDate or whatever makes sense...

If the date field is an EntryDate so it is equal to today where you can set the default in the field properties to =Date() then you could also set the DueDate the same way by making it's default value =Date()+30

Otherwise depending on how you're entering data in the table it could be done in a query on a form or ....


Hope that helps.

Scot
0
 
LVL 1

Expert Comment

by:Metroid
ID: 18011845
RHEDGES,

I read over your post again and since you are using a form to enter data just create a field next to the date entered field and use the formula that you are using (with just the slight modications that I gave you) and plug it into that field or use the one Pete provided (if you need assistance with that, then let us know).

Pete is correct that you can't do this within table design but either methods should work.

M
0
 
LVL 44

Expert Comment

by:GRayL
ID: 18016044
rhedges:  I case you didn't get it, you cannot enter an user defined function as a default.  Date(), Year(Date()), etc. are all instrinsic to Access and will pass, anything "you" the "user" defines will not.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question