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

lock a form with checkbox 1

Status
Not open for further replies.

Pampers

Technical User
Joined
Apr 7, 2004
Messages
1,300
Location
AN
Hi everyone,
Try to lock a form with a checkbox. I used this code, but doesn't work. Suggestions?

Code:
Private Sub Check95_AfterUpdate()
    If Check95 = True Then
    Me.RecordLocks = 1
    End If
End Sub

Pampers.

You're never too young to learn
 
Can you explain in words what you are trying to achieve here. What do mean by 'lock a form'?
 
hi lupins46,
i try to lock the records attached to the form so that the user can not edit or add records when the checkbox is checked. If he or she unchecks the box, recordlocks is set to 0

Pampers.

You're never too young to learn
 
Hi!

The properties you are looking for are Me.AllowEdits and Me.AllowAdditions.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
tnx jebry,
I aslo used a commandbutton to set the property, instead of a checkbox.
Code:
Private Sub Command99_Click()
Me.AllowEdits = True

an a afterupdate_event to set Me.AllowEdit to false again

Pampers.

You're never too young to learn
 
Did you get it to work? I didn't.

I dont know what could be wrong. I created a Check box and set those properties but it didnt work.

Thanks

 
hi mauricionava,
i did get it to work, but i used a commandbutton instead of a check box, because the check created some problems for using as a recordlocker. Here is how it works

By default you set your form on not allowing Edits (form properties) Edits = No [false]
then you create a commandbutton that puts AllowEditions = true as a click_event
Code:
Private Sub Command99_Click()
Me.AllowEdits = True
to put it back on false again, you create an afterupdate_event for your form and you put Me.AllowEdit = False

now you've locked your form until the user clicks the button to edit information. After the update, the form locks again



Pampers.

You're never too young to learn
 
We tend to get caught up here in the "how" of doing something; I'm curious about the "why." If any user can "unlock" the form in order to edit a record, what's the point? You've simply added one more step the user has to take to perform a simple task!

The Missinglinq


There's ALWAYS more than one way to skin a cat!
 
hi missinglinq ,
i agree - but there are some exceptions. For instance: the information already typed in, its accuracy is so crucial that you don't want user by accident change a value or a name, fi while scrolling through the records. That's the reason why i locked a form for a customer who is anxious something goes wrong...
or is there a better way to do 'secure' information?

Pampers.

You're never too young to learn
 
That's exactly why I wanted to lock the form.

Now, when I lock the form, it also locks all buttons. So my employees would have to click on the Edit button in order to click on the Report button.

Is there a way to only lock the textfields and checkboxes?

thanks
 
hi mauricionava ,
maybe you locked all the records (RecordLocks = yes); use the (Allow)Edit-option so the user cannot by accident change a record, but is still able add records, filter records, print etcetera.

Pampers.

You're never too young to learn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top