Freezing the fields on a form

chris_elevate

Registered User.
Local time
Today, 15:12
Joined
Apr 18, 2008
Messages
27
Hi,

Is there a way I can freeze out a customers details using a button on a form?

For example.... The cutomers ID has a drop down box. The customer is selected and their details then displayed below. i.e. their name address and telephone number.

Is there a way I can lock/freeze these details so the can only be changed if the a button has been pressed.

Thanks
 
Hi,

Is there a way I can freeze out a customers details using a button on a form?

For example.... The cutomers ID has a drop down box. The customer is selected and their details then displayed below. i.e. their name address and telephone number.

Is there a way I can lock/freeze these details so the can only be changed if the a button has been pressed.

Thanks
You can set the "Locked" property in the Data tab of the textbox' properties to lock the fields. Then you can unlock them using a button by adding code like the following:

txtYourTextBox.Locked = False

or if you want to use one button to both lock and unlock:

txtYourTextBox.Locked = Not txtYourTextBox.Locked

The latter will lock the textbox if it's unlocked and unlock the textbox if it's locked. Good luck!
 
Thanks,

Where abouts do I add the code: txtYourTextBox.Locked = Not txtYourTextBox.Locked ?

On the event? In VB?

Also...

Is there a way I can get it to lock all the fields at the same time and unlock them at the same time with the click of a button? i.e. using what you've suggest but it locking several items?

Thanks
 
The code goes in VBA in the OnClick event of a button. You can use it on as many textboxes as you like. E.g.:

Code:
Private Sub yourButton_Click()
 
txtBox1.Locked = False
txtBox2.Locked = False
txtBox3.Locked = False
 
End Sub
 
I would suggest setting the TAG property of the controls you want to lock to something consistent (e.g. LOCKME) then using a loop to lock them all.


Code:
Sub LockControls
 For each myControl in Me.Controls
  If myControl.tag = "LOCK_ME" then
   myControl.locked = true
  end if
 Next
End Sub
 
Thanks guys,

I've tried using Simplycongy's way of doing it and I can't get it to work.

This is the code I've got on the even proceedure of my button:

Private Sub lockfields_Click()
For Each myControl In Me.Controls
If myControl.Tag = "LOCK_ME" Then
myControl.Locked = True
End If
Next
End Sub

Any ideas?

Thanks
 
If you have put LOCK_ME in the tag of the control, this would do it:


Code:
Dim ctl As Control
If Not Me.NewRecord Then
   For Each ctl in Me.Controls
     If ctl.Tag = "LOCK_ME" Then
        ctl.Locked = True
     End If
  Next ctl
End If

You would also need to put this in the form's ON CURRENT event so that it would lock as you move from form to form
 
A couple of things:

1. Where abouts do I put LOCK_ME ? How do I do this?

2. How do I get to the forms ON CURRENT event?

3. This code need to put in the VB like this:
Private Sub lockfields_Click()
Dim ctl As Control
If Not Me.NewRecord Then
For Each ctl in Me.Controls
If ctl.Tag = "LOCK_ME" Then
ctl.Locked = True
End If
Next ctl
End If
End Sub

Thanks
 
tag01.png



tag02.png



tag03.png



tag04.png



tag05.png
 
Fantastic!!!

I've done all that!!

How do I now toggle the locked cells on and off? Do I create a button with an event? etc?

Thanks
 
Fantastic!!!

I've done all that!!

How do I now toggle the locked cells on and off? Do I create a button with an event? etc?

Thanks

Yeah, just do a button and use this:
Code:
Dim ctl As Control

   For Each ctl in Me.Controls
     If ctl.Tag = "LOCK_ME" Then
        ctl.Locked = [color=red]FALSE[/color]
     End If
  Next ctl
 
Thanks.

That works but it doens't seem to lock the cells again after it has been clicked for a second time. Is there a way to use the button like a toggle switch?

Bob is there any chance you could take a look at my other post. I've got the sum function working but I can't get it to work on the main form and not just on the subform. http://www.access-programmers.co.uk/forums/showthread.php?t=149721

Thanks
 
It won't lock the cells again until the record has been saved. You can use this in the click event of your lock button (before the lock code) to save the record if it has been modified:

If Me.Dirty Then Me.Dirty=False
 
I now have this on the click event of my button but it produces and error:

Code:
Private Sub lockfields_Click()
If Me.Dirty Then Me.Dirty = False
Dim ctl As Control
   For Each ctl In Me.Controls
     If ctl.Tag = "LOCK_ME" Then
        ctl.Locked = False
     End If
  Next ctl
End Sub

How can I correct this?
 
It won't lock the cells again until the record has been saved. You can use this in the click event of your lock button (before the lock code) to save the record if it has been modified:

If Me.Dirty Then Me.Dirty=False

Bob,
What are you using to make your graphics? They're great--- just like your site.
 
Bob,
What are you using to make your graphics? They're great--- just like your site.

SnagIt - a great program, easy to use, and actually very affordable ($39.99). I liked it so much while working at Providence Health System, that I bought a copy for home.
 
Ok this is what I'm getting (see attachment)

It's when I load the form.... press the lock button to let me edit some details and then press it again to lock it.
 

Attachments

  • screen-shot.gif
    screen-shot.gif
    56.2 KB · Views: 126

Users who are viewing this thread

Back
Top Bottom