using datediff() to disable for items

Gr3g0ry

Registered User.
Local time
Today, 14:17
Joined
Oct 12, 2017
Messages
163
hey. this is my code:

If paid = inst Then
'Me.submit.Enabled = False
Else if DateDiff("d", StartDate, now) >= 6 Then
Me.submit.Enabled = False
Else
Me.submit.Enabled = True
End If

i want to disable a button if the days between now and the startdate is less than 6.

the first option works but the date section doesnt. Suggestions ??
 
Use <6 on your ElseIf condition
 
thanks bruh. i had solved it though, using

diff = DateDiff("d", StartDate, now)
paid = Me.paininstall.Value
inst = Me.Installments.Value
start = Me.StartDate.Value


If paid = inst Then
Me.submit.Enabled = False
ElseIf diff >= 6 Then
Me.submit.Enabled = False
Else
Me.submit.Enabled = True
End If

thanks though bruh
 
You could simplify that to
Code:
    If paid = inst [COLOR="Red"]Or [/COLOR]DateDiff("d", StartDate, Now) < 6 Then
        Me.submit.Enabled = False
    Else
        Me.submit.Enabled = True
    End If
Personally not a great fan of ElseIf, much better and clearer to use a Select Case statement if you need lots of possible outcomes.
 

Users who are viewing this thread

Back
Top Bottom