donkey9972
Registered User.
- Local time
- Yesterday, 19:36
- Joined
- May 18, 2008
- Messages
- 183
Hi,
I have a form that has 2 fields. On the first field which is the date, I have my form setup that if there is no value all the other fields are disabled. Once a date is entered all the fields become enabled. Then on that same form I have a 2nd field and depending on the number entered there I want to have only specific fields become enabled. The problem I am having is that it appears to be an either or situation. How do I write an if..then (or some kind of loop) if the date field has the date and the aisles field has a number in it (1, 2, 3, 4....20) then the corresponding fields will be enabled. If there is no date and/or there is not number in the aisles field then nothing becomes enabled. This is the code I am using to enable the fields if there is a date entered. I have been able to get it to work also with the aisles depending on if there is a number entered in that field. But as I said I need it to be if both have an entry that the specific fields become enabled.
I have a form that has 2 fields. On the first field which is the date, I have my form setup that if there is no value all the other fields are disabled. Once a date is entered all the fields become enabled. Then on that same form I have a 2nd field and depending on the number entered there I want to have only specific fields become enabled. The problem I am having is that it appears to be an either or situation. How do I write an if..then (or some kind of loop) if the date field has the date and the aisles field has a number in it (1, 2, 3, 4....20) then the corresponding fields will be enabled. If there is no date and/or there is not number in the aisles field then nothing becomes enabled. This is the code I am using to enable the fields if there is a date entered. I have been able to get it to work also with the aisles depending on if there is a number entered in that field. But as I said I need it to be if both have an entry that the specific fields become enabled.
Code:
Public Sub EnableControl()
On Error Resume Next
Dim i As Integer
If IsNull(Me.txtDate) Then
For i = 1 To 40
Me("A" & i).Enabled = False
Next
Me.txtDate.SetFocus
GoTo ONE
Else
For i = 1 To 40
Me("A" & i).Enabled = Me.txtDate >= 0
Next
ONE:
End If
End Sub