I have a form with the following coding on click of a control. I am trying to always set ActiveXCtl0 to the current Monday when clicked. With this code, sometimes it works and sometimes it doesn't. can someone tell me what is wrong with my code?
Dim stDocname As String, bteSte As Byte, bteEnd As Byte
Dim dtest As Date, dteEd As Date
dtest = Me.ActiveXCtl0.Value
dteEd = Me.ActiveXCtl12.Value
bteSte = DatePart("w", dtest)
bteEnd = DatePart("w", dteEd)
Dim ctl0 As Control
Set ctl0 = Me!ActiveXCtl0
ctl0 = Date
If bteSte = 1 Then
Me.ActiveXCtl0 = Date - 6
Exit Sub
ElseIf bteSte = 3 Then
Me.ActiveXCtl0 = Date - 1
Exit Sub
ElseIf bteSte = 4 Then
Me.ActiveXCtl0 = Date - 2
Exit Sub
ElseIf bteSte = 5 Then
Me.ActiveXCtl0 = Date - 3
Exit Sub
ElseIf bteSte = 6 Then
Me.ActiveXCtl0 = Date - 4
Exit Sub
ElseIf bteSte = 7 Then
Me.ActiveXCtl0 = Date - 5
Exit Sub
ElseIf bteStet = 2 Then
Me.ActiveXCtl0 = Date
End If
After I get this to work I want ActiveXCtl12 to set to the Saturday exactly 4 weeks later. any suggestions on that too??
Dim stDocname As String, bteSte As Byte, bteEnd As Byte
Dim dtest As Date, dteEd As Date
dtest = Me.ActiveXCtl0.Value
dteEd = Me.ActiveXCtl12.Value
bteSte = DatePart("w", dtest)
bteEnd = DatePart("w", dteEd)
Dim ctl0 As Control
Set ctl0 = Me!ActiveXCtl0
ctl0 = Date
If bteSte = 1 Then
Me.ActiveXCtl0 = Date - 6
Exit Sub
ElseIf bteSte = 3 Then
Me.ActiveXCtl0 = Date - 1
Exit Sub
ElseIf bteSte = 4 Then
Me.ActiveXCtl0 = Date - 2
Exit Sub
ElseIf bteSte = 5 Then
Me.ActiveXCtl0 = Date - 3
Exit Sub
ElseIf bteSte = 6 Then
Me.ActiveXCtl0 = Date - 4
Exit Sub
ElseIf bteSte = 7 Then
Me.ActiveXCtl0 = Date - 5
Exit Sub
ElseIf bteStet = 2 Then
Me.ActiveXCtl0 = Date
End If
After I get this to work I want ActiveXCtl12 to set to the Saturday exactly 4 weeks later. any suggestions on that too??