Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

Can't prevent updates and allow new records on form/subform/subfor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AccessMan - 13 Mar 2008 15:27 GMT
I have a form with a subform that also contains a subform.  The Data Entry
property for each is set to No.  I would like to prevent users from updating
records on each form, but I would also like to allow them to create new
records on each form.  To achieve this, I set the Allow Edits property to No
on each form, while retaining the Yes setting for Allow Additions and Allow
Deletions.  The result is that I can create new records on the main form, but
not on either subform.  Am I stuck with this, or am I doing something wrong?

Thanks!!!
Allen Browne - 13 Mar 2008 15:56 GMT
Yes, that is how Access works.

If you set AllowEdits to No, you can't edit in any of the controls on the
main form. The subform control is a form on the main form, and so you cannot
edit in that control. Hence you can't use the subform.

To work around that, leave the form's AllowEdits property set to Yes, and
lock the controls instead. Here's the code to loop through controls and
lock/unlock them, including any subforms (nested to any level):
    Locking bound controls on a form and subforms
at:
   http://allenbrowne.com/ser-56.html

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have a form with a subform that also contains a subform.  The Data Entry
> property for each is set to No.  I would like to prevent users from
[quoted text clipped - 10 lines]
>
> Thanks!!!
AccessMan - 13 Mar 2008 16:14 GMT
Thanks.  Unless I misunderstood though, locking the controls prevents the
user from creating new records, doesn't it?

> Yes, that is how Access works.
>
[quoted text clipped - 23 lines]
> >
> > Thanks!!!
Allen Browne - 13 Mar 2008 16:26 GMT
The article contains the code for locking and unlocking the form.

If you call the code in the form's Current event, you can use it to lock
existing records, and unlock new records:

   Private Sub Form_Current()
       Call LockBoundControls(Me, Not Me.NewRecord)
   End Sub

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Thanks.  Unless I misunderstood though, locking the controls prevents the
> user from creating new records, doesn't it?
[quoted text clipped - 28 lines]
>> > not on either subform.  Am I stuck with this, or am I doing something
>> > wrong?
AccessMan - 13 Mar 2008 17:10 GMT
I think I see what you are saying now.  Would a lot of modification be
required to automatically lock bound controls (or the entire form/subforms)
for existing records, and automatically unlock for new records?

> The article contains the code for locking and unlocking the form.
>
[quoted text clipped - 37 lines]
> >> > not on either subform.  Am I stuck with this, or am I doing something
> >> > wrong?
Allen Browne - 13 Mar 2008 17:16 GMT
Probably no changes at all.

Copy'n'paste the code.

Use the form's Current event instead of the Load event /button click as
suggested in the article.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I think I see what you are saying now.  Would a lot of modification be
> required to automatically lock bound controls (or the entire
[quoted text clipped - 50 lines]
>> >> > something
>> >> > wrong?
AccessMan - 13 Mar 2008 17:36 GMT
I'm slowly building my comfort level with VBA.  Would a more direct solution
be to set Allow Edits to No for the form and subforms by default, and reset
this property to Yes for all if the user clicks any of the New Record
buttons?  I would also need to reset the properties back to No after the new
record is saved.

> Probably no changes at all.
>
[quoted text clipped - 57 lines]
> >> >> > something
> >> >> > wrong?
Allen Browne - 14 Mar 2008 03:03 GMT
You can try that.

My experience is that AllowEdits is way to restrictive in practice. For
example, if you use an unbound combo for navigating to a record, or unbound
controls so the user can filter the form, there are all useless if
AllowEdits is set to Yes.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> I'm slowly building my comfort level with VBA.  Would a more direct
> solution
[quoted text clipped - 4 lines]
> new
> record is saved.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.