I am trying to loop through controls by creating a string of the control name, each loop makes a numeric value in the name advance. Something like "Control01" becomes "Control02" etc. I then use the value of this control to compare against the current date "Date" and change checkboxes if the item is "Open", "Due" or "Late"
Somehow my concantonated string name saved in a string variable is not referencing the form field in my IF statement below.
For example I have bolded one example in the code box called "txtPlan". If I break the code before the IF statement and place ?txtplan in the debug window I get
forms!frmdranddrbfmdates!dtDRDate02Plan
Which is the actual name of the form control.
If I then add a "?" in front of the value I just returned in the debug window such as
?forms!frmdranddrbfmdates!dtDRDate02Plan
I get 2/2/08 which is the actual value in the control so I am getting to the control.
[red]How do I modify my if statement below to reference the control and return a date as above? Currently it always falls through to the last else, apparently never really making the comparison to Date[/red]
THANKS
Somehow my concantonated string name saved in a string variable is not referencing the form field in my IF statement below.
For example I have bolded one example in the code box called "txtPlan". If I break the code before the IF statement and place ?txtplan in the debug window I get
forms!frmdranddrbfmdates!dtDRDate02Plan
Which is the actual name of the form control.
If I then add a "?" in front of the value I just returned in the debug window such as
?forms!frmdranddrbfmdates!dtDRDate02Plan
I get 2/2/08 which is the actual value in the control so I am getting to the control.
[red]How do I modify my if statement below to reference the control and return a date as above? Currently it always falls through to the last else, apparently never really making the comparison to Date[/red]
THANKS
Code:
Private Sub Form_load()
Dim c As Integer
Dim n As String
Dim txtActual As String
Dim txtPlan As String
Dim ckOpen As String
Dim ckDue As String
Dim ckLate As String
n = ""
c = 1
Do While c < 13
If c < 10 Then n = "0" & CStr(c) Else n = CStr(c)
txtActual = "Forms!frmdranddrbfmdates!dtDRDate" & n & "Actual"
[b]txtPlan = "Forms!frmdranddrbfmdates!dtDRDate" & n & "Plan"[/b]
ckDue = "Forms!frmdranddrbfmdates!ckdrduedate" & n
ckLate = "Forms!frmdranddrbfmdates!ckdrlatedate" & n
ckOpen = "Forms!frmdranddrbfmdates!ckdropendate" & n
If Not (IsNull(txtActual)) Then
If txtActual < Date Then ckLate = -1 Else
If txtActual < Date + 14 Then ckDue = -1 Else ckOpen = -1
End If
c = c + 1
Loop
Me.Refresh
End Sub