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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
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 |