Question : How to Disable all textboxes, command buttons, combo boxes etc.. on form:

PROBLEM DESCRIPTION
Disable all textboxes, commcand buttons, comboboxes, tabs etc.... on the form
 "frmProjects_NEW_VER1"
Until the user has entered both the Project name and Project number

WHAT I TRIED
I put this code in the form " "frmProjects_NEW_VER1" on the load event and it did not work:
Dim c As Control
On Error Resume Next
For Each c In Me.Controls
 c.Enabled = c.Name = "ProjectName"
Next c
____________________________________

What do I need to do?
_______________________________________

To recreate problem:
1. Log In
2. Clock 'New Project"
3. Notice that the user can enter all information on the
frmProjects_NEW_VER1 and click SAVE without entering the Project name or Project number.


Answer : How to Disable all textboxes, command buttons, combo boxes etc.. on form:

Question 1. Do I replace the code I put in the ON OPEN EVENT with:
Private Sub VerifyNameAndNumber()
If Len(Me.ProjectName) > 0 And Len(Me.ProjectNumber) > 0 Then
    Dim c As Control
        For Each c In Me.Section(0).Controls
            If c.ControlType = acTextBox Or c.ControlType = acCommandButton Then
                'MsgBox c.Name
                c.Enabled = True
            End If
        Next c
End If

No, don't you remember?
What did I post here 33293015 ?
Here is the entire post again:
<I think we need to add some code to disable the Comboboxes?>
Bingo!

So try this:

Private Sub VerifyNameAndNumber()
If Len(Me.ProjectName) > 0 And Len(Me.ProjectNumber) > 0 Then
    Dim c As Control
        For Each c In Me.Section(0).Controls
            If c.ControlType = acTextBox Or c.ControlType = acCommandButton Or c.ControlType = acCombobox Then
                'MsgBox c.Name
                c.Enabled = True
            End If
        Next c
End If

;-)

No the $50,000 Dollar question is:
Can you adapt this to code *enable the comboboxes in the "VerifyNameAndNumber" sub procedure?

;-)

Jeff
\
Random Solutions  
 
programming4us programming4us