459,516 Members | 1,148 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

# Date Math for Access 97

 P: n/a I have 2 Date fields DuesLastPaid DateDuesDue I want to enter the date of payment in last paid, and have one year from now show in the dues field In the AfterUpdate property of the last paid I used the expression builder and have =[DateDuesDue]=[DuesLastPaid]+DateAdd("yyyy",1,[DuesLastPaid]) I have also tried in the AfterUpdate =[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid]) If I (maybe not?) understand the Help example for the DateAdd function, it is supposed to add 1 year to last paid and put the result in dues due But... Nothing happens, nothing shows in dues due Is the above expression wrong... or should I put the expression in another place (On Exit... or...???) I have also tried a default value in DateDuesDue of =DateAdd("yyyy",1,[DuesLastPaid]) And that does nothing as well Trying to get the dues due field to default to the last paid field, plus 1 year, has me stumped One last thing that SHOULD make no difference is that I set the record source for the form to a very simple query of all data fields and order by the LastName field so the data shows on the form by last name (table is indexed on hidden autonumber) Thanks, John Nov 13 '05 #1
9 Replies

 P: n/a J wrote: I have 2 Date fields DuesLastPaid DateDuesDue I want to enter the date of payment in last paid, and have one year from now show in the dues field In the AfterUpdate property of the last paid I used the expression builder and have =[DateDuesDue]=[DuesLastPaid]+DateAdd("yyyy",1,[DuesLastPaid]) I have also tried in the AfterUpdate =[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid]) In the AfterUpdate event change it to Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid]) assuming the name of the field to be updated is DateDuesDue If I (maybe not?) understand the Help example for the DateAdd function, it is supposed to add 1 year to last paid and put the result in dues due But... Nothing happens, nothing shows in dues due Is the above expression wrong... or should I put the expression in another place (On Exit... or...???) I have also tried a default value in DateDuesDue of =DateAdd("yyyy",1,[DuesLastPaid]) And that does nothing as well Trying to get the dues due field to default to the last paid field, plus 1 year, has me stumped One last thing that SHOULD make no difference is that I set the record source for the form to a very simple query of all data fields and order by the LastName field so the data shows on the form by last name (table is indexed on hidden autonumber) Thanks, John Nov 13 '05 #2

 P: n/a >In the AfterUpdate event change it to Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid])assuming the name of the field to be updated is DateDuesDue I did that, and get an error message The object doesn't contain the Automation object Me. I checked (reran) my install and already had all the data access components installed so have no idea why using Me. would product an error Could this be a result of running Access97 on WinXpSp2 ??? Nov 13 '05 #3

 P: n/a J wrote: In the AfterUpdate event change it to Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid])assuming the name of the field to be updated is DateDuesDue I did that, and get an error message The object doesn't contain the Automation object Me. I checked (reran) my install and already had all the data access components installed so have no idea why using Me. would product an error Could this be a result of running Access97 on WinXpSp2 ??? Why don't you copy the code you have in the event so folks can see what you are doing. Also, ensure DuesLastPaid is the NAME of the control you want to calculate on, not the controlsource. Nov 13 '05 #4

 P: n/a >Why don't you copy the code you have in the event so folks can see whatyou are doing. Also, ensure DuesLastPaid is the NAME of the control youwant to calculate on, not the controlsource. Data fields on the form are DateDuesDue and DuesLastPaid, the text box names and control source are the same, since the data fields were copied to the form directly from the field list Code is (in AfterUpdate of DuesLastPaid) Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid]) Error is The object doesn't contain the Automation object 'Me.' I checked (reran setup) my install and already have all the data access components installed so have no idea why using the Me. function would product an error Could this be a result of running Access97 on WinXpSp2 ??? Thanks, John Nov 13 '05 #5

 P: n/a J wrote:Why don't you copy the code you have in the event so folks can see whatyou are doing. Also, ensure DuesLastPaid is the NAME of the control youwant to calculate on, not the controlsource. Data fields on the form are DateDuesDue and DuesLastPaid, the text box names and control source are the same, since the data fields were copied to the form directly from the field list Code is (in AfterUpdate of DuesLastPaid) Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid]) Error is The object doesn't contain the Automation object 'Me.' I checked (reran setup) my install and already have all the data access components installed so have no idea why using the Me. function would product an error Could this be a result of running Access97 on WinXpSp2 ??? Thanks, John Enter the word Me. does a drop down list appear? Select the field name if it does. If it doesn't, then try to compile the code for loaded modules...you might have a problem there. Click to the left of the Me..., on the bar, to step into the code when it is run. Run the form. Update the event. When droped into the code, go to the immediate window and enter ? Me.[DateDuesDue] ? Me.DateDuesDue ? DateAdd("yyyy",1,[DuesLastPaid]) See if something occurs there. Nov 13 '05 #6

 P: n/a J wrote:Why don't you copy the code you have in the event so folks can see whatyou are doing. Also, ensure DuesLastPaid is the NAME of the control youwant to calculate on, not the controlsource. Data fields on the form are DateDuesDue and DuesLastPaid, the text box names and control source are the same, since the data fields were copied to the form directly from the field list Code is (in AfterUpdate of DuesLastPaid) Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid]) Error is The object doesn't contain the Automation object 'Me.' I checked (reran setup) my install and already have all the data access components installed so have no idea why using the Me. function would product an error Could this be a result of running Access97 on WinXpSp2 ??? Could be a result of misuse of dots versus bangs :-) Try Me![DateDuesDue] or Me.Controls("DateDuesDue") -- This sig left intentionally blank Nov 13 '05 #7

 P: n/a J wrote:In the AfterUpdate event change it to Me.[DateDuesDue]=DateAdd("yyyy",1,[DuesLastPaid])assuming the name of the field to be updated is DateDuesDue I did that, and get an error message The object doesn't contain the Automation object Me. I checked (reran) my install and already had all the data access components installed so have no idea why using Me. would product an error Could this be a result of running Access97 on WinXpSp2 ??? Did you create an event handler procedure? Your previous attempt was in an expression, that is not the same. To create an event handler: * set the AfterUpdate property of the control to [Event Procedure] you can select this value from the list * click the three dot button that now appears to the right of this property (if it doesn't, move off the property first) * you arrive in the code module for the form. Put the Me.whatever statement there. -- Bas Cost Budde, Holland http://www.heuveltop.nl/BasCB/msac_index.html I prefer human mail above automated so in my address replace the queue with a tea Nov 13 '05 #8

 P: n/a Oops, for some reason I didn't see the rest of the thread before I posted my interrupt. Never mind. -- Bas Cost Budde, Holland http://www.heuveltop.nl/BasCB/msac_index.html I prefer human mail above automated so in my address replace the queue with a tea Nov 13 '05 #9

 P: n/a John, it is unclear to me where you are entering your code, whether it is in the properties of the control, the code builder for the AfterUpdate event, the code of the particular form, a global module, or some other module. Nov 13 '05 #10

### This discussion thread is closed

Replies have been disabled for this discussion.