Trouble calculating Date (1 Viewer)

Dave 14867

Registered User.
Local time
Today, 13:51
Joined
Jan 1, 2017
Messages
56
Hello,

I am trying to calculate a date in a table based on another that has been entered already, essentially the expiration date is always 1 day later that it was made. What I want is for the WaterIntExpDate to be calculated as 1 day after the WaterIntLot date after it is entered. I have tried the code below but I get errors.


Can someone please help me out.

Private Sub WaterIntLot_AfterUpdate()
Me.WaterIntExpDate = DateAdd("d", 1, Me.WaterIntLot)

End Sub

Thanks

Dave
 

MarkK

bit cruncher
Local time
Today, 13:51
Joined
Mar 17, 2004
Messages
8,179
I have tried the code below but I get errors.
Two things...
1) what errors do you get?
2) it is a mistake to store two values where those stored values can be said to "vary directly" with each other. Rather, you should store the first value, and always calculate the second from the first when and if you need it.

hth
Mark
 

Dave 14867

Registered User.
Local time
Today, 13:51
Joined
Jan 1, 2017
Messages
56
Mark,

I don't remember the actual error flagged, I will try to record them in future issues. I have to store the 2 values for regulatory reasons and for traceability reasons, I agree with you actually but I have to.

I found what was causing the error and corrected it. Before I had used the code, I had put a formula on the ExpDate text box on the form and it didn't like it. My issue was I believed it would be written to the table and it wasn't so I had to use the code to put it into the table. When I removed the formula in the text box on the form, the code worked fine. It did calculate the date perfectly on the form and I was confused as to why it wasn't placing it into the table, then I remembered that what is on the form is for display only.

I am learning, plenty of things to learn and remember but getting better every day. You folks are a great help.

Thanks

Dave
 

Users who are viewing this thread

Top Bottom