enabled button if date range is 15 or 16 days

icemonster

Registered User.
Local time
Today, 11:19
Joined
Jan 30, 2010
Messages
502
does anyone have an idea how to write this? like i have a button that only enables = true of the date range is 15 or 16 days or also 30 days. thanks.
 
look up the dateadd or datediff functions. they should give you some idea of how to do it
 
already did mate, but cant seem to figure it out, can anyone show me a sample code?
 
Lets suppose you already know the difference in days between the lower and upper date (you did not elaborate on this topic). You can then perform a Select Case statement

Code:
Select Case DaysCount
    Case 15, 16, 30
       Me.CmdButton.Enabled = True
    Case Else
       Me.CmdButton.Enabled = False
End Select

You would put this on your On Current event of the form.
 
sorry for not elaborating. ok, so whats the best way to make subtract the days? like this? DateDiff ("d", #15/10/2010#, #22/11/2010#? but how i write it that whatever they choose on fieldA(startdate) and fieldB(enddate) would be the variable to subtract them?
 
Code:
Dim Elapsed As Integer

Elapsed = DateDiff("d",Me.Lower,Me.Upper)

Code:
Select Case Elapsed
 .....
End Select

Or

Code:
Select case DateDiff("d",Me.Lower,Me.Upper)
  ....
End Select
 
its not working :(

i wrote it like this:

Private Sub Form_Current()
Select Case DateDiff("d", Me.txtStatDate, Me.txtEndDate)
Case 14, 15, 16
Me.cmdtest1.enabled = True
Case Else
Me.cmdtest1.enabled = False
End Select
Me.lblListInfo.Caption = Me.lstScheduleRecords.ListCount - 1 & " Schedule Records:"
End Sub
 

Users who are viewing this thread

Back
Top Bottom