Simple Form lock on open (with two subforms)?

michaeljohannes

Registered User.
Local time
Today, 10:04
Joined
May 3, 2007
Messages
67
Hello,

I think this is possible with a crafty use of

Code:
me.allowedits = false

but I'm not sure.

I have a form that has two subforms in it. I simply want to make this form (and the two sub forms!) LOCKED so the user has to click a command button to unlock them. It's not an issue of security, rather an issue of accidentally updating, deleting information undesirably.

When I use the above code in the "On Open" event (or "On Load" for that matter" ) the main form is not editable (the form is locked), but, the above code does not lock the two subforms from being edited.

Any ideas? I think it's a simple fix, but I'm not sure.

Thanks!
Mike
 
If the command button is on the main form then:

Forms!YourMainFormNameHere.Form.YourSubformCONTAINERName.AllowEdits = False
 
Why not set the subform's "Locked" to true in the properties option and then, on clicking the command button do:
Code:
Me.subform1.Locked = False
 
Thank you both! I have one more quickie...

Is there a way I can also set the background color to be green when the form is locked, and then red when the form data is editable? Another reminder for the user that they are in 'edit mode'?
 
Me.Detail.BackColor = RGB(255, 0, 0) for red

Me.Detail.BackColor = RGB(0, 255, 0) for green
 
This is what I have so far:


Code:
On Open

  Me.Form1.locked = True
  Me.Subform1.Locked = True
  Me.Subform2.Locked = True

The two subforms ARE locked, but the main form (form1) is not.

If I change the above code by replacing the first line to:

me.allowedits = false

The code works. Then all I have to do is create a command button that undoes the above locks/allowedits on open.

I can make this work, but I'm just curious why the me.form1.locked = true, does NOT lock the main form? Is the syntax still incorrect?

Thanks for your help!

Mike
 
Me.Detail.BackColor = RGB(255, 0, 0) for red

Me.Detail.BackColor = RGB(0, 255, 0) for green

Remember to use the correct syntax for the subform if you are changing that color. Also, you can set your color to any valid color that Access uses, so the easy way to do it is to set an item to the color you want and then look at the BackColor number (like 238834) and then put that in.
 
What if the back color is a hex value? (#04617B)

would it be

Me.detail.BackColor = HEX(04617B)

?
 
Never tried it, so I don't know. You could give it a shot and find out.
 
I did! And it sort of works...

The interesting thing is that

Hex(123456) would be fine... but not Hex(12345B) with a letter as the last character! the VB editor doesn't like the fact it's a letter and not a number...
 
the reason why the subform locks is because you are locking the control on the main form which happens to be the subform, which is not quite the same as disallowing edits on the subform

the main form itelf isnt a control, so doesnt have a locked property - hence the allowedits instead

hopre this makes sense
 

Users who are viewing this thread

Back
Top Bottom