Hello,
I am really hoping to receive help in this area.
Here is some background info.
I have a form based on a query.
The Query is based on a table with 18 task fields all having 18 different dates. The dates are used to determine if a particular task has been completed or not. There are 18 tasks. Each record is a person that has 18 tasks to complete. All tasks must be completed within a years time. If not the person is considered "Overdue"
Query is using the dates within the 18 separate task fields and calculating the number of days to today's date.
Now the form I am using has for each record a person that has 18 task fields within textboxes that are populated with the results from the calculations of the above query. I am looking to use a For...Each...Next statement to cycle through all 18 textboxes (for each record) and determine if any of the 18 textboxes (for each record) are above 365 days. If so I want to use a label that will state "Overdue". If any of the 18 textboxes (for each record) are over 365 days then the label still states "Overdue"
If all 18 textboxes (for each record) are under 365 days then I want the label to state "Current"
This is an example of the code I am trying to use:
Private Sub Form_Load()
Dim myTextBox As TextBox
For Each myTextBox In Controls
If myTextBox > 365 Then
labelCurrent.Caption = "Overdue"
Else: labelCurrent.Caption = "Current"
End If
Exit For
Next
End Sub
I can't get this to work!! I have tried other combinations but to no avail. I am a new VB programmer and I am trying to learn. Is there anyone that can help me with this problem? Also, if you need more info I am glad to provide it. Thank
Mike
I am really hoping to receive help in this area.
Here is some background info.
I have a form based on a query.
The Query is based on a table with 18 task fields all having 18 different dates. The dates are used to determine if a particular task has been completed or not. There are 18 tasks. Each record is a person that has 18 tasks to complete. All tasks must be completed within a years time. If not the person is considered "Overdue"
Query is using the dates within the 18 separate task fields and calculating the number of days to today's date.
Now the form I am using has for each record a person that has 18 task fields within textboxes that are populated with the results from the calculations of the above query. I am looking to use a For...Each...Next statement to cycle through all 18 textboxes (for each record) and determine if any of the 18 textboxes (for each record) are above 365 days. If so I want to use a label that will state "Overdue". If any of the 18 textboxes (for each record) are over 365 days then the label still states "Overdue"
If all 18 textboxes (for each record) are under 365 days then I want the label to state "Current"
This is an example of the code I am trying to use:
Private Sub Form_Load()
Dim myTextBox As TextBox
For Each myTextBox In Controls
If myTextBox > 365 Then
labelCurrent.Caption = "Overdue"
Else: labelCurrent.Caption = "Current"
End If
Exit For
Next
End Sub
I can't get this to work!! I have tried other combinations but to no avail. I am a new VB programmer and I am trying to learn. Is there anyone that can help me with this problem? Also, if you need more info I am glad to provide it. Thank
Mike