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!

Edit Button

Form Basics

Edit Button

by  Kherozen  Posted    (Edited  )
Something it's useful to have a form serving as a viewer so data can't be add and/or edit and be able to change it as a editor on a click of a button


Here's the way I do it :

The Forms and subforms properties is set to
.AllowAdditions = false
.AllowEdits = False

then create a button that will contain the following code in the On Open events

[tt]
Me.AllowAdditions = True
Me.AllowEdits = True
'if there's no subform don't include the rest of the code
For Each myControl In Controls
Select Case myControl.ControlType
Case acSubform
myControl.Form.AllowAdditions = True
myControl.Form.AllowEdits = True
End Select
Next
[/tt]

The advantage of my code is that you don't need to enter the form/subforms name and you can add/remove subforms within the form without having to change that part of the code...code it and forget it!(just like the chicken in the ads).

there's surely some bad points to my code but like a good politician, I won't mention them


jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top