473,618 Members | 3,064 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set a form's/subform's "Allow Edits" property?

sueb
379 Contributor
I have a form/subform combination that I sometimes want to open disallowing Edits, Additions, and Deletions, depending on which password-protected menu option I'm coming from. (My menu structure is pretty simple, so I'm not using a switchboard, but rather some forms with controls on them.)

How do I manipulate those properties, of both the form and its subform, (in the little procedure that checks the password) before I open the form?
Jan 27 '11 #1
15 21134
beacon
579 Contributor
Check out this link: http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

It shows you how to access the the AllowEdits property in VBA. There are additional links and instruction for the other Allow-type properties.
Jan 29 '11 #2
sueb
379 Contributor
That is a very helpful article. But I don't have the syntax correct for opening a form with its RecordsetType set to Snapshot. What I'm trying gives me a 'type mismatch':

Expand|Select|Wrap|Line Numbers
  1.     Dim stDocName As String
  2.     Dim stLinkCriteria As String
  3.  
  4.     stDocName = "Patient_IUR_Overview"
  5.  
  6.     ' Disallow Edits, Additions, and Deletions in both the Overview and Abbreviated forms
  7.     DoCmd.OpenForm stDocName, , , , RecordsetType = Snapshot, stLinkCriteria
  8.  
Feb 1 '11 #3
ADezii
8,834 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. Dim strPassword As String
  2.  
  3. 'sueb will be able to Edit the Main Form (Orders) but NOT
  4. 'the SubForm (Orders SubForm)
  5. strPassword = "sueb"
  6.  
  7. Select Case strPassword
  8.   Case "Admininstrator"                             'Allow Main/SubForm Edits
  9.     Me.AllowEdits = True
  10.     Me![Orders SubForm].Form.AllowEdits = True
  11.   Case "sueb", "ADezii", "YaDa"                     'Allow Main Form Edits only
  12.     Me.AllowEdits = True
  13.     Me![Orders SubForm].Form.AllowEdits = False
  14.   Case "John", "Harry", "Peter", "Paul", "Mary"     'SubForm only
  15.     Me.AllowEdits = False
  16.     Me![Orders SubForm].Form.AllowEdits = True
  17. End Select
Feb 1 '11 #4
sueb
379 Contributor
Oh, that's nice and tidy, ADezii, and I'm going to save it in my code treasure box.

However, currently my users don't sign in individually, and I'm trying a little different approach. My main menu offers three choices. Two of the choices share some forms in common, except that one choice allows you to edit the data and the other doesn't. I have a global constant ("ReadOnly") that the choices set appropriately, and the shared forms, in their "On Open" events, check that constant to see whether they should set their RecordsetType to "Snapshot" or not.

All the forms are working fine except for the subform on one of the forms. I can't seem to touch it properly. Here's how the main form behaves "On Open" (I got this from the link provided by beacon):

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Const conSnapshot = 2
  3.     If ReadOnly Then
  4.         Forms!Patient_IUR_Overview.RecordsetType = conSnapshot
  5.     End If
  6. End Sub
  7.  
but similar code in the subform's "On Open" event tells me that it can't find the form ("run-time error 2450"). I tried putting this code in "On Load" (what is the difference, anyway?), and tried referencing the subform within the main form's "On Open" event, all to no avail.
Feb 1 '11 #5
sueb
379 Contributor
Any other ideas about how I can get this subform to set its RecordsetType when I open its parent form?
Feb 2 '11 #6
ADezii
8,834 Recognized Expert Expert
I cannot understand why the following Code will not work:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.   'Set the RecordsetType of SubForm to Snapshot
  3.   Me![<SubForm_Name>].Form.RecordsetType = 2
  4. End Sub
Feb 2 '11 #7
sueb
379 Contributor
I know I'm being completely dense about this, but I've tried a number of permutations of syntax (as you'll see in the following code, which contains only a fraction of them), and I just can't get this to stop saying it can't find either the subform (IURs_Abbreviat e_subform) or the main form (Patient_IUR_Ov er). This code is in the subform; is it supposed to be in the main form or something? That seems weird to me, since the main form has no problem setting its own RecordsetType OnOpen.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     If ReadOnly Then
  3.         'Forms!Patient_IUR_Overview!IURs_Abbreviated_subform.RecordsetType = conSnapshot
  4.         'Forms![Patient_IUR_Overview]![IURs_Abbreviated_subform].Form.RecordsetType = conSnapshot
  5.         'Forms![Patient_IUR_Overview].[IURs_Abbreviated_subform].Form.RecordsetType = conSnapshot
  6.         Me![IURs_Abbreviated_subform].Form.RecordsetType = conSnapshot
  7.     Else
  8.         'Forms!Patient_IUR_Overview!IURs_Abbreviated_subform.RecordsetType = conDynaset
  9.         'Forms![Patient_IUR_Overview]![IURs_Abbreviated_subform].Form.RecordsetType = conDynaset
  10.         'Forms![Patient_IUR_Overview].[IURs_Abbreviated_subform].Form.RecordsetType = conDynaset
  11.         Me![IURs_Abbreviated_subform].Form.RecordsetType = conDynaset
  12.     End If
  13. End Sub
  14.  
Feb 2 '11 #8
ADezii
8,834 Recognized Expert Expert
Can you Upload a Scaled Down Version of the DB? It has to be something relatively simple.
Feb 2 '11 #9
sueb
379 Contributor
Yes, ADezii, I'll do that tomorrow when I get back to work. Thanks!

And I'm sure you're right: it's got to be something simple that I'm just overlooking.
Feb 3 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1841
by: John Baker | last post by:
Hi: I have a query which supports a form. Te form is used to edit, update and change records in the table the query is based on. It all works fine EXCEPT that the "New" record (blank updatable record) always appears as the end of the form (i.e. the bottom), whereas it would be very helpful if it appeared at the beginning (the top of the form). Can anyone suggest a way to make this happen? Regards
2
3829
by: chacquard | last post by:
Hi, I've been working on a form that contains a subform. The fields in the main form are EvendId, EventName, Date, time, place, etc.. These fields cannot be edited (locked = yes and activated = no) In the subform the fields are EventId, TicketNo, Qty, Section, Row, Seat,etc... I use this subform to see the list of tickets for the event and to add new tickets. When I open my form, the focus goes to the last record.
7
2637
by: Sally | last post by:
In a subform that has no records, what is the white area? If a subform has records and you scroll the records, what is the white area after the last record? I would like to be able to click in these white areas and run code. Thanks, Sally
6
9333
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is a checkbox with a control source named "MARK" (boolean) from customer table. I can check and uncheck individual records fine. Then I created 2 command buttons named "Select All" and "Deselect All". The Onclick property of these buttons runs code...
1
1656
by: Eric E | last post by:
Hi all, I have a subform placed on a tab control, and I'm having a terrible time with proper tab order. I'm trying to allow the user to tab from the last control on my subform to a control on the same page on the tab control on the parent form. The control (a button) on the subform executes the following code On Key Down: Private Sub AddContactButton_KeyDown(KeyCode As Integer, Shift As Integer)
8
2040
by: Martin | last post by:
I hope not, but, I think the answer to this question is "it can't be done". Northwind sample database. Orders form. Go to a new record. Select a customer in "Bill To:" Don't enter any products whatsoever. Now click or page up/down away from this new record. You just created a new order without a single item having been ordered. Not something a user should be able to do.
0
13738
NeoPa
by: NeoPa | last post by:
Intention : To prepare a WHERE clause for multiple field selection, but to ignore any fields where the selection criteria are not set. ONLY WORKS WITH TEXT FIELD SELECTIONS. Scenario : You have a table (tblMember) containing information for various people. Table Name=tblMember Field; Type; IndexInfo MemberID; AutoNumber; PK Surname; String
3
2216
by: Kelii | last post by:
I've been beating my head against this problem for the last several days, and I haven't found a decent solution yet. So I'm turning to the group for some moral support or better yet some answers. Background: I want the user to be able to close the form by using the "x" button in the window title bar, I do not want to disable this. I have found a nice solution in the Access Developer's Handbook that disables the "x", however I am hoping...
25
20543
by: tekctrl | last post by:
Anyone: I have a simple MSAccess DB which was created from an old ASCII flatfile. It works fine except for something that just started happening. I'll enter info in a record, save the record, and try to move to another record and get an Access error "Record is too large". The record is only half filled, with many empty fields. If I remove the added data or delete some older data, then it saves ok and works fine again. Whenever I'm...
0
8207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8650
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8593
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2582
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.