I have three pairs of command buttons whose enabled properties are set to
disabled. I want each of then to become enabled on form load on three
separate dates. The code that I have written for this to happen is mentioned
below:
If Date >= #7/1/2005# Then
cmdAllot6.Enabled = True
cmdReq6.Enabled = True
ElseIf Date >= #7/1/2006# Then
cmdAllot7.Enabled = True
cmdReq7.Enabled = True
ElseIf Date >= #7/1/2007# Then
cmdAllot8.Enabled = True
cmdReq8.Enabled = True
End If
If I change the date on my computer to say 23-Mar-2006, cmdAllot6 and
cmdReq6 become enabled on form load. However, if the date is changed to
23-Mar-2010, the other two pairs of command buttons do not become enabled.
There seems to be something wrong with the code.
I would appreciate if someone can rescue me urgently.
JaRa - 23 Mar 2005 16:35 GMT
Is this what you want?
If Date >= #7/1/2005# AND Date < #7/1/2006# Then
cmdAllot6.Enabled = True
cmdReq6.Enabled = True
ElseIf Date >= #7/1/2006# AND Date < #7/1/2007# Then
cmdAllot7.Enabled = True
cmdReq7.Enabled = True
ElseIf Date >= #7/1/2007# AND Date < #7/1/2008# Then
cmdAllot8.Enabled = True
cmdReq8.Enabled = True
End if
- Raoul
> I have three pairs of command buttons whose enabled properties are set to
> disabled. I want each of then to become enabled on form load on three
[quoted text clipped - 19 lines]
>
> I would appreciate if someone can rescue me urgently.
Dennis - 23 Mar 2005 16:37 GMT
You need to put your latest date in the 'If' first. 23-Mar-2010 is greater or
equal to 7/1/2005 so the first part of the 'if' is true and it never gets to
the Else part.
> I have three pairs of command buttons whose enabled properties are set to
> disabled. I want each of then to become enabled on form load on three
[quoted text clipped - 19 lines]
>
> I would appreciate if someone can rescue me urgently.
Dennis - 23 Mar 2005 16:41 GMT
Further to my last post. Just take out the Else's and have them as individual
If statements.
> I have three pairs of command buttons whose enabled properties are set to
> disabled. I want each of then to become enabled on form load on three
[quoted text clipped - 19 lines]
>
> I would appreciate if someone can rescue me urgently.
Steve Schapel - 23 Mar 2005 20:09 GMT
Alylia,
Try it like this...
cmdAllot6.Enabled = Date >= #7/1/2005#
cmdReq6.Enabled = Date >= #7/1/2005#
cmdAllot7.Enabled = Date >= #7/1/2006#
cmdReq7.Enabled = Date >= #7/1/2006#
cmdAllot8.Enabled = Date >= #7/1/2007#
cmdReq8.Enabled = Date >= #7/1/2007#

Signature
Steve Schapel, Microsoft Access MVP
> I have three pairs of command buttons whose enabled properties are set to
> disabled. I want each of then to become enabled on form load on three
[quoted text clipped - 19 lines]
>
> I would appreciate if someone can rescue me urgently.