Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

Problems with if statements

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alylia - 23 Mar 2005 16:23 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.