code help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to disable a button depending on the
max "sdate" in the table "totals". So, if the table has
already been refreshed yesterday, I would like to disable
the button. I have written the code...

If Date - 1 = max(totals.SDATE) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
End If

But, i have problems with max(totals.sdate)

Thansk
 
I would like to disable a button depending on the
max "sdate" in the table "totals". So, if the table has
already been refreshed yesterday, I would like to disable
the button. I have written the code...

If Date - 1 = max(totals.SDATE) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
End If

But, i have problems with max(totals.sdate)

Thansk

If Date - 1 = DMax("[SDate]","totals") Then

Why are you both disabling and making the control Not Visible.
One or the other is all you need do.
If they can't see it, they can't click it, and if they can't click it,
what difference does it make if they see it or not,
 
Fred
The code below does not disable the command button even
though the sdate in totals equals 9/22/04 (stored as short
date formet). I have tried using control boxes to check
the values and they work...Getting very frustrated with
this issue. Thanks for your help

If ((Date - 1) = DMax("[SDate]", "[totals]")) Then
Me![Command1].Enabled = False
Else
Me![Command1].Enabled = True
End If
-----Original Message-----
I would like to disable a button depending on the
max "sdate" in the table "totals". So, if the table has
already been refreshed yesterday, I would like to disable
the button. I have written the code...

If Date - 1 = max(totals.SDATE) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
End If

But, i have problems with max(totals.sdate)

Thansk

If Date - 1 = DMax("[SDate]","totals") Then

Why are you both disabling and making the control Not Visible.
One or the other is all you need do.
If they can't see it, they can't click it, and if they can't click it,
what difference does it make if they see it or not,
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
Fred
The code below does not disable the command button even
though the sdate in totals equals 9/22/04 (stored as short
date formet). I have tried using control boxes to check
the values and they work...Getting very frustrated with
this issue. Thanks for your help

If ((Date - 1) = DMax("[SDate]", "[totals]")) Then
Me![Command1].Enabled = False
Else
Me![Command1].Enabled = True
End If
-----Original Message-----
I would like to disable a button depending on the
max "sdate" in the table "totals". So, if the table has
already been refreshed yesterday, I would like to disable
the button. I have written the code...

If Date - 1 = max(totals.SDATE) Then
Me![Command1].Enabled = False
Me![Command1].Visible = False
End If

But, i have problems with max(totals.sdate)

Thansk

If Date - 1 = DMax("[SDate]","totals") Then

Why are you both disabling and making the control Not Visible.
One or the other is all you need do.
If they can't see it, they can't click it, and if they can't click it,
what difference does it make if they see it or not,
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.

1) Is the datatype stored in SDate a date datatype or a text datatype?

2) If it is a Date datatype, do this in the code event:

MsgBox (date-1) & " " & DMax("[SDate]", "[totals]")
MsgBox (date-1) = DMax("[SDate]","Totals")

The first msgbox will display the value of yesterday's date and the
latest date in the table.
The second msgbox should say True (or -1)

3) Does the value stored in SDate include a time value,
i.e. 9/22/04 08:30:00 AM?
(Note: how the field is formatted is irrelevant)
If so, then date-1 will never = SDate unless the Time value is exactly
midnight.

4) If the first box returns the correct values, and the second returns
false, then change the code to

Date-1 = Format(DMax("[SDate]","Totals"),"mm/dd/yy")

and see what happens.
 
Back
Top