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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock/Unlock toggle button

Status
Not open for further replies.

kevin531

Technical User
Sep 25, 2002
33
0
0
US
hello, how do i make a toggle button that when depressed, allows one to enter data. When not depressed, locks the fields and doesn't allow data to be entered?

-Kevin531
 
Hi Kevin!

What I would do is just change the caption of the button and then key my code off of what the caption says. For example:

Private Sub YourButton_Click()

If YourButton.Caption = "Lock Record" Then
YourText1.Locked = True
YourCombo1.Locked = True
etc, or loop through the controls
YourButton.Caption = "Unlock Record"
Else
YourText1.Locked = False
etc. as above
YourButton.Caption = "Lock Record"
End If

End Sub

Of course, you can also throw in a check of the user trying to unlock the record to see if the user has the appropriate security level for that action.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Sorry, this didn't work right. i received a bunch of errors ect. is there a way to either lock or unlock all the controls rather than loop through all the controlls?

-kevin531
 
Hi!

If you want to lock/unlock everything then you can use Me.AllowEdits = False to lock and Me.AllowEdits = True. This is simpler, but you will need to make sure that the property is set where you want it when you move to a new record. Of course, you would need to do the same with the caption on the button.

hth
Jeff Bridgham
bridgham@purdue.edu
 
How do i set these options and specify which way the toggle is defaulted to? is there a way to have the caption of the toggle button change when it is pressed? i'm not good with visual basic so any extra help would be greatly appreciated. thanks.

-kevin531
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top