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

AllowEdits on a SubForm 1

Status
Not open for further replies.

dtutton

Technical User
Mar 28, 2001
58
DE
I have a sub-form on a form.

With AllowEdits turned on all data on the form and subform can be edited.

With AllowEdits turned off, nothing can be edited - fine. So I then put in a command button on the form to AllowEdits with a on click event. This allowed edits on form but NOT on sub-form.

Can anyone help on how to allow edits, deletions, additions on the sub-form aswell.

Thanks
 
Subform properties are separate from the properties of the main form. They are independent. The only dependence between the two is on the child/master fields in the recordsets that the two forms use.

It is necessary to open the Subform in design view and add a button to toggle the allow edits for that form. The new button will work only on the subform level and it will not effect the master form.
Hope this helps.
 
I don't know the exact syntax, haven't worked with subforms much, but I though you could say something like ThisForm.Subform.AllowEdits = TRUE. So, you could have one button that would have two lines, one for the main form and one for the subform setting the AllowEdits to true.

Anyone else back me up on this? Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
On forms where I want to prevent accidental changes, I lock all editable controls and provide the user with an Edit command button.

When this button is clicked the code "unlocks" the controls I want the user to be able to change.

This works for subform controls also.
Larry De Laruelle
larry1de@yahoo.com

 
I tried the same approach as Larry (AllowEdits False on main form) and a button to turn them back on. However it only works on the Main Form.

The properties on the sub-form are Allowedits True.

Should I put a further command button on the sub-form to handle this ?

I tried the code:

Private Sub Edit_Record_Click()
Me.AllowEdits = True
Me.subMySubform.Form.AllowEdits = True
End Sub

But got a compile error.

I apologize for ignorance, Im new to this - used to program in clipper/dbase which seems a long way away!

ps Im using Access97

Thanks
 
I probably should have been more specific.

I leave the AllowEdit property on the subform set to Yes so I don't have to tinker with the subform from the main.

From the main form On_Open I set the locked property of the subform to True to prevent users from making changes/additions. I pretty much lock down all the controls on the form so that users can't mistakenly change data (of course they can still screw it up after clicking on Edit).

From an On_Click event (Add Record and Edit Record command buttons) I set Locked to False to allow changes/additions. I also use an Undo command and a Save command to again set the Locked property to True.

Been using this for a while with subforms and have not had any problems with users making unwanted changes that I have to later clean up.
Larry De Laruelle
larry1de@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top