A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

displaying generated date in a form



 
 
Thread Tools Display Modes
  #1  
Old July 9th, 2004, 01:12 AM
Joseph Atie
external usenet poster
 
Posts: n/a
Default displaying generated date in a form

Currently I have a form with the following feilds; [purchase date] [warranty length] & [warranty expiration]

what i want to do is calculate the warranty expiration date using the purchase date and the warranty length.

SO

I set the default value of the warranty expiration field to:

=DateAdd("yyyy",[Warranty length],[Purchae Date])

and added a macro to warranty length, so that on change it will requery warranty expiration.

Currently, I get no result the field remains blank.

Suggestions???
  #2  
Old July 9th, 2004, 02:32 AM
Graham R Seach
external usenet poster
 
Posts: n/a
Default displaying generated date in a form

Joseph,

Putting the formula in the control's DefaultValue property only helps when
you first move to that record. If you want to refresh the field based on
changes made to other controls, you need to affect its Value property. So,
in the AfterUpdate event for both [Warranty length] AND [Purchase Date], add
the following:
RecalculateExpiry

Then add the following procedure to the form:
Private Sub RecalculateExpiry()
Me("waranty expiration") = DateAdd("yyyy", Nz(Me("Warranty length"),
1), Nz(Me("Purchase Date"), Date()))
End Sub

To avoid getting a blank field when you first move to the record, try using
this in the control's DefaultValue property:
=DateAdd("yyyy", Nz([Warranty length], 1), Nz([Purchase Date], Date()))

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"Joseph Atie" Joseph wrote in message
...
Currently I have a form with the following feilds; [purchase date]

[warranty length] & [warranty expiration]

what i want to do is calculate the warranty expiration date using the

purchase date and the warranty length.

SO

I set the default value of the warranty expiration field to:

=DateAdd("yyyy",[Warranty length],[Purchae Date])

and added a macro to warranty length, so that on change it will requery

warranty expiration.

Currently, I get no result the field remains blank.

Suggestions???



  #3  
Old July 12th, 2004, 03:26 AM
sleek
external usenet poster
 
Posts: n/a
Default displaying generated date in a form

Ive never used this method before. I must be doing something wrong.

When i try to execute the function (by changing one of the values in the open form) I get an error message about not being able to find the macro RecalculateExpiry.

what am i missing?

I simple opened the code section for the form and copy/pasted the function as you have it written, then change the field names. Oh and i added the added the afterupdate function call as "RecalculateExpiry"

"Graham R Seach" wrote:

Joseph,

Putting the formula in the control's DefaultValue property only helps when
you first move to that record. If you want to refresh the field based on
changes made to other controls, you need to affect its Value property. So,
in the AfterUpdate event for both [Warranty length] AND [Purchase Date], add
the following:
RecalculateExpiry

Then add the following procedure to the form:
Private Sub RecalculateExpiry()
Me("waranty expiration") = DateAdd("yyyy", Nz(Me("Warranty length"),
1), Nz(Me("Purchase Date"), Date()))
End Sub

To avoid getting a blank field when you first move to the record, try using
this in the control's DefaultValue property:
=DateAdd("yyyy", Nz([Warranty length], 1), Nz([Purchase Date], Date()))

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"Joseph Atie" Joseph wrote in message
...
Currently I have a form with the following feilds; [purchase date]

[warranty length] & [warranty expiration]

what i want to do is calculate the warranty expiration date using the

purchase date and the warranty length.

SO

I set the default value of the warranty expiration field to:

=DateAdd("yyyy",[Warranty length],[Purchae Date])

and added a macro to warranty length, so that on change it will requery

warranty expiration.

Currently, I get no result the field remains blank.

Suggestions???




  #4  
Old July 12th, 2004, 07:26 AM
Graham R Seach
external usenet poster
 
Posts: n/a
Default displaying generated date in a form

Sleek,

what am i missing?
Don't know. Post what you have now.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"sleek" wrote in message
...
Ive never used this method before. I must be doing something wrong.

When i try to execute the function (by changing one of the values in the

open form) I get an error message about not being able to find the macro
RecalculateExpiry.

what am i missing?

I simple opened the code section for the form and copy/pasted the function

as you have it written, then change the field names. Oh and i added the
added the afterupdate function call as "RecalculateExpiry"

"Graham R Seach" wrote:

Joseph,

Putting the formula in the control's DefaultValue property only helps

when
you first move to that record. If you want to refresh the field based on
changes made to other controls, you need to affect its Value property.

So,
in the AfterUpdate event for both [Warranty length] AND [Purchase Date],

add
the following:
RecalculateExpiry

Then add the following procedure to the form:
Private Sub RecalculateExpiry()
Me("waranty expiration") = DateAdd("yyyy", Nz(Me("Warranty

length"),
1), Nz(Me("Purchase Date"), Date()))
End Sub

To avoid getting a blank field when you first move to the record, try

using
this in the control's DefaultValue property:
=DateAdd("yyyy", Nz([Warranty length], 1), Nz([Purchase Date],

Date()))

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"Joseph Atie" Joseph wrote in message
...
Currently I have a form with the following feilds; [purchase date]

[warranty length] & [warranty expiration]

what i want to do is calculate the warranty expiration date using the

purchase date and the warranty length.

SO

I set the default value of the warranty expiration field to:

=DateAdd("yyyy",[Warranty length],[Purchae Date])

and added a macro to warranty length, so that on change it will

requery
warranty expiration.

Currently, I get no result the field remains blank.

Suggestions???






 




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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date criteria for report from form Peter Woodhead Setting Up & Running Reports 5 July 17th, 2004 12:19 PM
If statement Doug Worksheet Functions 9 June 28th, 2004 06:13 AM
synchronizing form and list box Deb Smith Using Forms 8 June 21st, 2004 08:15 PM
Word 2002 form letter date format Jonny Mailmerge 1 April 25th, 2004 02:28 PM
Does date fall between two ranges? MR Worksheet Functions 4 January 14th, 2004 04:08 PM


All times are GMT +1. The time now is 03:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.