Calculating the date!

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

I have 3 text boxes on my form tbServiceDate(Date) , tbWarn1(Number) ,
tbDayWarn1 (Date)
How can I have in form open event tbWarnDate1 will give me the date being
tbServiceDate plus tbWarn1
i.e. 12 May 2010 + 7 = 19 May 2010
Me.tbDayWarn1 = Me.tbServiceDate + Me.tbWarn1
 
Am 10.06.2010 10:48, schrieb Bob Vance:
I have 3 text boxes on my form tbServiceDate(Date) , tbWarn1(Number) ,
tbDayWarn1 (Date)
How can I have in form open event tbWarnDate1 will give me the date being
tbServiceDate plus tbWarn1
i.e. 12 May 2010 + 7 = 19 May 2010
Me.tbDayWarn1 = Me.tbServiceDate + Me.tbWarn1

Hi there,

use the DateAdd-Function. In the Load event like this:

Me.tbDayWarn1 = DateAdd("d", Me.tbWarn1, Me.tbServiceDate)

Regards
Jörn
 
Bob

I've not been able to determine in which circumstances/conditions the
following happens, but I've had to deal with it:

1. An Access function/expression stops working and throws an error
message (not a consistent one).
2. The expression includes the Me. phrase, but it refers to an object
I created, rather than a property or method of the "Me".
3. I change the expression to "Me! something, and it works!

As I said, inconsistently, but I'm guessing that portions of Access got more
rigorous about how "Me." and "Me!" are interpreted.

Your expression uses "Me.", but refers to objects (textboxes) you created.
I'm guessing that you could use:

Me!tbDayWarn1 = Me!tbServiceDate + Me!tbWarn1

provided you format the tbDayWarn1 to display a date value.

Your code would be a bit more readable and self-documenting if you use the
DateAdd(), as suggested elsethread...

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Jörn Bosse said:
Am 10.06.2010 10:48, schrieb Bob Vance:

Hi there,

use the DateAdd-Function. In the Load event like this:

Me.tbDayWarn1 = DateAdd("d", Me.tbWarn1, Me.tbServiceDate)

Regards
Jörn

Thanks Jorn, worked great, just one little thing I have a control to take
away the date in tbServiceDate
tbServiceDate.value = ""
but unless I highlight the tbServiceDate and delete it I can get the date to
dissapear from tbDayWarn
Can I change
tbServiceDate.value = ""
Regards Bob
 
Well sorry i didn´t get it. Do you want to delete the tbDayWarn1 value
or do you want it to stay if tbServiceDate has been cleared?

Regards
Jörn

Am 10.06.2010 20:35, schrieb Bob Vance:
 
Thanks Jorn , I got around it using this code:
tbServiceDate.value = ""
tbDayWarn1.value = ""
tbDayWarn2.value = ""
tbDayWarn3.value = ""
tbDayWarn4.value = ""
tbDayWarn5.value = ""
tbDayWarn6.value = ""

So when i cleared the date ii also cleared the due dates as
well.........Regards Bob
 
Back
Top