Changing read/write properties

G

google3luo359

Hello.

This one is a bit beyond my capabilities at the moment.

I have a tabbed form with 4 Pages.
I have code that selects the Page to open depending on the userID.

I would like to somehow have code so that the user can read/write to
the subforms on this Page but not be able to write/edit to the other 3
Pages' subforms.

The next user logs into the tabbed form and their Page opens. Similar
setup. They can read/write to their page's subforms but only read the
other Pages' subforms.

Any help would be appreciated! Ric
 
G

google3luo359

Barry said:
Take a look at the AllowEdits and AllowAdditions properties in Help.

Thanks Barry.

I'm trying to keep this code as simple as possible. I saw that Snapshot
can also be used in this case.

Here's an example code to disallow editing:

Const conSnapshot = 2
Forms!Employees.RecordsetType = conSnapshot

What would I have for my situation where I have a Parent form with
tabs?
Parent form is fmAEP and tab control is TabAEP.
Pages are; Grade9, Grade10, Grade11, Grade12.

Const conSnapshot = 2
Forms!fmAEP.RecordsetType = conSnapshot (didn't
work)
and
Const conSnapshot = 2
Forms!fmAEP!tabAEP.Pages(0).RecordsetType = conSnapshot
(didn't work)

TIA Ric
 
G

Guest

You can't change the recordset type that way. Snapshot can only be used when
you are declaring a recordset object in code. Besides, your trying to use
your code on the parent form.

Are you using Access security to authenticate users? If so, you could give
rights to each subform or its underlying table/query based on the group. That
might be more straightforward.

Barry
 
G

google3luo359

Barry said:
You can't change the recordset type that way. Snapshot can only be used when
you are declaring a recordset object in code. Besides, your trying to use
your code on the parent form.

Are you using Access security to authenticate users? If so, you could give
rights to each subform or its underlying table/query based on the group. That
might be more straightforward.


HI Barry,

No, I'm not using access security. I won't be needing it with this
db.
I have set up a simple password system (with forms) that is adequate
for this db.

This db is for students, and if they have the ability to mess around
with additional Tab pages they can access, they'll do it!

I've looked at the Help file for AllowEdits and couldn't find anything
with examples for my situation with a Form and its Tabs/Pages.

TIA Ric
 
G

google3luo359

Barry said:
AllowEdits should be applied to each subform, not the tabs pages.

OK I understand the concept of what you are saying, but applying it
is another matter.

Here's the setup I now have:
fmA with its TabControl tbA .

tbA has four pages (1,2,3,4)
Each page has its own subform (sfm1, sfm2, sfm3, sfm4).

According to what you are saying I need to refer to these subforms in
my code.
I tried Forms![fmA]![sfm1].AllowEdits = False
but I received this message:
'Object doesn't support this property or method'

At this stage I'm just trying to get AllowEdits to work anywhere.
The idea is to code so that only the Page that is open allows edits,
the other three don't.

TIA Ric
 
G

Guest

You need to refer to the form, not the frmA's subform control.

Forms![fmA]![sfm1].Form.AllowEdits = False

or
Me.sfm1.Form.AllowEdits = False

Barry

Barry said:
AllowEdits should be applied to each subform, not the tabs pages.

OK I understand the concept of what you are saying, but applying it
is another matter.

Here's the setup I now have:
fmA with its TabControl tbA .

tbA has four pages (1,2,3,4)
Each page has its own subform (sfm1, sfm2, sfm3, sfm4).

According to what you are saying I need to refer to these subforms in
my code.
I tried Forms![fmA]![sfm1].AllowEdits = False
but I received this message:
'Object doesn't support this property or method'

At this stage I'm just trying to get AllowEdits to work anywhere.
The idea is to code so that only the Page that is open allows edits,
the other three don't.

TIA Ric
 
G

google3luo359

You need to refer to the form, not the frmA's subform control.
Forms![fmA]![sfm1].Form.AllowEdits = False

or
Me.sfm1.Form.AllowEdits = False

Barry

With much hope and anticipation I tried the code. Unfortunately it
didn't work.
Here's what I have:

DoCmd.OpenForm "fmA"

If Me!cboStudNum.Column(2) = "9" Then
Forms![fmA]!tabA.Pages(0).SetFocus
Forms![fmA]!sfm2.Form.AllowEdits = False
Forms![fmA]!sfm3.Form.AllowEdits = False
Forms![fmA]!sfm4.Form.AllowEdits = False

I opened pages 2,3, and 4 and was able to add/edit data.
Can you see anything obvious that I'm doing wrong?

TIA Ric
 
G

google3luo359

Well actually I am finally making some progress! :)

I reasoned that in order to stop me from making additions to the form
I'd need more code, so I added the following:

Forms![fmA]!sfm1.Form.AllowEdits = False
Forms![fmA]!sfm1.Form.AllowAdditions = False
Forms![fmA]!sfm1.Form.AllowDeletions = False

Now this worked.... BUT... everything on the form was greyed out!
I couldn't see anything in the form
The idea is to be able to see other records on the other forms but not
be able to add/edit/delete them.

TIA Ric
 
G

google3luo359

Barry said:
You need to refer to the form, not the frmA's subform control.

Forms![fmA]![sfm1].Form.AllowEdits = False

or
Me.sfm1.Form.AllowEdits = False


OK, I finally figured out how to get this thing working properly.
I'm locking all the controls on the Pages as default and then
using Locked = False for the Page that the student is permitted to
edit.

Ric
 
G

Guest

Sounds like a good solution. Glad you got it working.
Barry

Barry said:
You need to refer to the form, not the frmA's subform control.

Forms![fmA]![sfm1].Form.AllowEdits = False

or
Me.sfm1.Form.AllowEdits = False


OK, I finally figured out how to get this thing working properly.
I'm locking all the controls on the Pages as default and then
using Locked = False for the Page that the student is permitted to
edit.

Ric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top