Between operator in my VBA Code isn't working

dianna_vasher

New member
Local time
Today, 16:17
Joined
Jul 12, 2015
Messages
5
How do I use the Between in this? I want to set a value of 10 dollars to AfterHours if User enters a start time that is between START and FINISH.

Private Sub StartTime_AfterUpdate()
Dim Start As Date
Dim Finish As Date

Start = #12:00:00 AM#
Finish = #6:00:00 AM#
If Me.ActiveControl Between Start And Finish Then
Me.AfterHours = 10
End If

End Sub:banghead:
 
If memory serves, Between is only valid in SQL. You'd need to test >= and <=.
 
If memory serves, Between is only valid in SQL. You'd need to test >= and <=.

Start = #12:00:00 AM#
Finish = #6:00:00 AM#
If Me.ActiveControl >= Start And <= Finish Then
Me.AfterHours = 10
End If

isnt debugging eaither :(
 
You have to repeat the field:

If Me.ActiveControl >= Start And Me.ActiveControl <= Finish Then
 
Start = #12:00:00 AM#
Finish = #6:00:00 AM#
If Me.ActiveControl => Start And <= Finish Then

Nope.
 
YES!!!!!! Thank you!!!!!:D:D IT WORKS!

Private Sub StartTime_AfterUpdate()
Dim Start As Date
Dim Finish As Date

Start = #12:00:00 AM#
Finish = #6:00:00 AM#
If Me.ActiveControl >= Start And Me.ActiveControl <= Finish Then
Me.AfterHours = 10
Else: Me.AfterHours = 0
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom