A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

code help



 
 
Thread Tools Display Modes
  #1  
Old September 23rd, 2004, 05:50 PM
external usenet poster
 
Posts: n/a
Default code help

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
  #2  
Old September 23rd, 2004, 07:41 PM
fredg
external usenet poster
 
Posts: n/a
Default

On Thu, 23 Sep 2004 09:50:53 -0700,
wrote:

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.
  #3  
Old September 23rd, 2004, 08:00 PM
external usenet poster
 
Posts: n/a
Default

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-----
On Thu, 23 Sep 2004 09:50:53 -0700,
wrote:

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.
.

  #4  
Old September 23rd, 2004, 10:26 PM
fredg
external usenet poster
 
Posts: n/a
Default

On Thu, 23 Sep 2004 12:00:50 -0700,
wrote:

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-----
On Thu, 23 Sep 2004 09:50:53 -0700,
wrote:

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.

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to RTF very slow when code is present in Access report. [email protected] Setting Up & Running Reports 11 September 14th, 2004 08:17 PM
sending same data to multiple noncorresponding cells rclark General Discussion 13 September 13th, 2004 06:49 PM
Conversion of excel vba code to access vba filnigeria General Discussion 5 July 15th, 2004 02:23 AM
customizing "documentor" output W Garrard Database Design 12 May 24th, 2004 03:07 AM


All times are GMT +1. The time now is 11:35 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.