473,508 Members | 2,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MS Access adding dates

Hi,
Does anyone know how to make 1 date field 6 months ahead of another in
ms access?
Eg, I have a field called "startdate" where a date is entered. I want
"offprobationdat" equal to startdate + 3 months.
Thanks a lot.

*** Sent via Developersdex http://www.developersdex.com ***
Dec 26 '05 #1
5 3396
On Mon, 26 Dec 2005 02:45:09 GMT, jim Bob <fr****@gmail.com> wrote:
Hi,
Does anyone know how to make 1 date field 6 months ahead of another in
ms access?
Eg, I have a field called "startdate" where a date is entered. I want
"offprobationdat" equal to startdate + 3 months.
Thanks a lot.

*** Sent via Developersdex http://www.developersdex.com ***


Sub StartDate_AfterUpdate()

If Not IsNull(Me.StartDate) Then
Me.OffProbationDate = DateAdd("m",3,Me.Startdate)
Else
Me.OffProbationDate = Null
End If

End Sub
Wayne Gillespie
Gosford NSW Australia
Dec 26 '05 #2


Hi Wayne,
Thanks a lot for the reply.
How do i USE this code?
Eg do i put it as a macro or module or paste the code into the table in
Design view?

Cheers
*** Sent via Developersdex http://www.developersdex.com ***
Dec 26 '05 #3
On Mon, 26 Dec 2005 04:55:07 GMT, jim Bob <fr****@gmail.com> wrote:


Hi Wayne,
Thanks a lot for the reply.
How do i USE this code?
Eg do i put it as a macro or module or paste the code into the table in
Design view?

Cheers
*** Sent via Developersdex http://www.developersdex.com ***


You need to enter the data in a Form in order to make this work. Entering the data directly into a table will not
trigger the calculation.

Create a form which includes StartDate, OffProbationDate and any other fields you require from your table. You can use
the Form Wizard to create this form if you want.

Once you have the form, open it in design view and click on the StartDate control and open it's properties sheet. (right
click - properties).

Click on the Event tab and select AfterUpdate. Click the (...) button which appears at the right of the property. Select
Event Procedure. The form's code module will open with the header and footer for the procedure auto created as such -

Sub StartDate_AfterUpdate()

End Sub

Paste the following code between the header and footer lines -

If Not IsNull(Me.StartDate) Then
Me.OffProbationDate = DateAdd("m",3,Me.Startdate)
Else
Me.OffProbationDate = Null
End If

Open the form in normal mode. When you enter a date in StartDate, OffProbationDate will be set to 3 months ahead of the
StartDate. If StartDate is deleted OffProbationDate will also be deleted.
Wayne Gillespie
Gosford NSW Australia
Dec 26 '05 #4

"jim Bob" <fr****@gmail.com> wrote in message
news:VO****************@news.uswest.net...
Hi,
Does anyone know how to make 1 date field 6 months ahead of another in ms access?
Eg, I have a field called "startdate" where a date is entered. I want "offprobationdat" equal to startdate + 3 months.
Thanks a lot.

*** Sent via Developersdex http://www.developersdex.com ***


jib Bob,

UPDATE UnknownTable
SET offprobationdat = DateAdd("m", 3, startdate)
Sincerely,

Chris O.
Dec 26 '05 #5

Hi Guys,
Thanks a lot for your help!!
I've sorted it out via a form and an update query.

*** Sent via Developersdex http://www.developersdex.com ***
Dec 27 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5375
by: Miguelito Bain | last post by:
hi everybody. i'm trying to find out what you can and can't do with/in calculated fields. any help, pointers, and/or advice would be greatly appreciated. i'm a newbie, but i want to learn, and...
6
4712
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
9
1891
by: Neil | last post by:
I have been coding with ASP for some time now. I am using an ACCESS database. I am in the UK and wish to use DD/MM/YYYY format for dates. I have had no end of problems and possible solutions to...
0
2706
by: neoteny2 | last post by:
I need MS Access to automatically create reports/subreports based on specific criteria. I am building a database in Access 2003 with different locations/sites. I have the "sites" table created...
1
5152
by: Brad | last post by:
Thanks for taking the time to read my question. I have a table of data that has Date, Data and Category. I need to show, in a report, each Categories Data by Date. The Date has to be it's own...
3
5512
by: rsbutterfly16 | last post by:
hi all, I have a front end access database (mdb) with a sql server backend for my tables. I have an form in which I have created a store procedure in sql server, and i have a form created and also...
5
2541
by: Henning M | last post by:
Hi all, I having some problems with Access and selecting records between dates.. When I try this in access, it works fine!! "Select * from Bilag Where Mdates Between #1/1/2006# And...
5
3147
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
25
2230
by: DFS | last post by:
I have a job to automatically import Excel data and post to database tables, via a point-click interface. Choose-file-and-it-does-the-rest kind of thing. Cient stores data in columns in his...
14
2885
by: awayne | last post by:
I am working with MS VB 6.5. I am putting together a MS Access (MS Access 2000) database for work to keep track of the projects and their status that we've done. I use MS Access to run a "Make-table...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.