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

Prevent Users from Deleting Records in a SubForm's SourceObject 1

Status
Not open for further replies.

NorwalkPhil

Programmer
Jun 9, 2009
4
US
I have an unbound main form "myMainForm" with a subform "mySubForm". MySubForm's sourceobject is a table "myTable". The main form is used for data entry (via various textboxes, comboboxes, etc.) and the data in the subform is used as reference by the user doing the data entry.

The properties of myMainForm are: AllowEdits = Yes, AllowDeletions = No, AllowAdditions = No.
The properties of the subform object (mySubForm) are: Enabled = Yes and Locked = Yes (that's all there is...)

The locked records on mySubForm prevents the user from changing any of the values of the sourceobject table (and this is good). However, the user can still delete a record!

How can I prevent the user from deleting records in this reference only table?

Also, by using a subform with a table as a sourceobject allows the user sort and filter capabilities on all of the columns in the table (and this is good). However, the user is prompted to save the table when they close the main form if they did sort any of the columns!

How can I close the form without saving the table without prompting the user?

I hope I asked the two questions clearly and thanks for your attention.
 
In the Load event procedure of the main form:
Me!mySubForm.Form.AllowDeletions = False

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya NorwalkPhil . . .

Is not [blue]PHV's[/blue] answer obvious! [surprise]



See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
The properties of the subform object (mySubForm) are: Enabled = Yes and Locked = Yes (that's all there is...)

Thats when you have the sub form CONTROL selected, now click again and you will have the sub form itself selected. Now you can see the sub forms properties, such as allowadditions/allowdeletions. I'm thinking your subform is a datasheet? That must be why its trying to save the table order?

Make a simple query "SELECT MyTable.* FROM MyTable;" and choose the query as the recordsource for your sub form. That should take care of it, and be a better design to boot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top