Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Module Error 1

Status
Not open for further replies.

Hayton

Technical User
Oct 17, 2001
257
NZ
Hi Guys,

I have this module called LockControls. It has 2 functions in it:
Public Function LockControls()
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
With ctl
.Locked = True
.Enabled = False
End With
End If
Next
End Function


Public Function UnLockControls()
Dim ctl As Control
For Each ctl In Screen.ActiveForm.Controls
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
With ctl
.Locked = False
.Enabled = True
End With
End If
Next
End Function

When I call the function UnLockControls I get an error message - Compile Error: Expected Variable or procedure, no module.

Private Sub cmdMod_Click()

If cmdMod.Caption = "Modify or Add Data" Then
cmdMod.Caption = "Review Mode"

Call UnLockControls

Else
If cmdMod.Caption = "Review Mode" Then
cmdMod.Caption = "Modify or Add Data"

Call LockControls
End If

End If

End Sub

Not being a programmer I would appreciate any comments or help.

Hayton McGregor

 
I don't know if it's the source of your problem, but it's always dangerous to have multiple objects with the same name, in this case, your module and a function within the module.

HTH,

Ken S.
 
Rename the module and your code will work.
Code:
Private Sub cmdMod_Click()
    If cmdMod.Caption = "Modify or Add Data" Then
        cmdMod.Caption = "Review Mode"
        UnLockControls
    Else
        cmdMod.Caption = "Modify or Add Data"
        LockControls
    End If
End Sub


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top