Not Allow Date Past This Thursday

D

Dave Elliott

Why does this code not work? Text108 is a date field as well as Text106!
Format m/d/yy
If Text108('s date) is past Text106('s date), then cancel
Let's say Text108 date is 11/04/04 then cancel the update, because
Text106 date is Thursday 11/03/04
This date (Text106) would be the last date acceptable in the pay period
The Control field is named (Work Date) where the code should be triggered
on the before update event.

If (Text108) > (Text106) Then
Cancel = True
MsgBox "Enter a work date within the work week"
End If

If the date enetered in the control Work Date is a date beyond;
Thursday of the current week then a message and cancel = True. (Format
m/d/yy) for control Work Date
The code neeeds to be triggered on the before update event.
This is a payroll module and uses the current weeks dates to calculate,
current week is 10/28/04 thru 11/03/04
 
R

Rick B

Why is is named Text### if it is a date field?

Text is different than a date and I don't think you can really perform math
functions on text.

I'd start by looking at that.

Rick B
 
D

Dave Elliott

The control is bound, however the Text Boxes should not make a difference
if they are not, The code is triggered on the control. i.e. Work Date
The text box is formatted for a date m/d/yy, this should not be a problem
 
R

Rick B

I'm pretty sure it will unless you are converting that text box into a date.

A date in Access is not ##/##/## it is a number 0145665 that Access turns
into a date and time. You can't perform math such as...

If 01/04/05 > 0145665


It just does not work.

I could be way off here, but I'm guessing this is the problem.

Rick B
 
R

Rick B

A question in another group might help you here...


----------------------------------------------------------------------------
------
Here's a simple example (done in the immediate window):

? cDate("3/1/2004") - 1
2/29/2004

cDate() converts the text to a date. In this case, if you want to know what
the last day of the month for February is, then set it for the first day of
the following month and then back up 1 day.

HTH
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top