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

How to prevent the user from writing in a SubForm 1

Status
Not open for further replies.

Husameddin

Technical User
Mar 4, 2003
17
GB
Hello everyone

I created subforms from queries so that the queries will appear in the subform, the problem is that I am afraid that the user might write something in the subform and that might affect the queries and the form will give the wrong result or miss up the database and thequeries, so I was wondering if I could use a VB code to prevent this from happening or is there any other option apart from VB cods.

I have more than 10 subforms from 10 queries all in one big form....I mean one form holds 10 sub forms using Tab Control with 10 pages
I am using Microsoft office xp

I need help please


 
There are two ways you can handle this (actually, three, but we'll save the third way for the end of post).

First, you need to realize that when you have subforms embedded in a tabbed control on a main form,each time you open the main form, ALL the queries for the tabbed subforms will execute to retrieve their data. This may or may not be a very efficient way to do things..just a thought.

One way to prevent editing in a form is to set it's "AllowEdits" and AllowDeletions" properties to NO. Open the form in design view, open the property sheet for the form, and set these two properties - they are in the DATA tab, I believe.

Another way is to use a chunk of code in the main form' Tab control "Got Focus" event, actually in each of the PAGE's Got Focus event, to set the form in the control's AllowEdits and AllowDeletions properties to NO.

The latter method should be used if you use the forms in any other process in your application. They would only be "read only" in your tab control guy.

The third method is to 1) educate your users so they don't make boneheaded mistakes, and 2) bulletproof your data and application so when they do anyway, you catch them and make them confirm their boneheadedness..in otherwords, make it very difficult for them to shoot themselves in the foot...

I've always shied against the idea of a FORM as a read-only device..forms are designed primarily for data editing and maintenance. If you want a read-only vehicle for users to look at data with, use a report.

HTH

Jim


If at first you don't succeed, skydiving probably isn't for you!
Another free Access forum:
More Access stuff at
 
Thank you very much WildHare...I did as you said in the first suggestion and it is working fine. I didn’t use reports because I wanted all the information to be in the same page and that will be easy for the user to navigate through, I used the report to print the data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top