We help IT Professionals succeed at work.

How open form in read only mode

SteveL13
SteveL13 asked
on
1,316 Views
Last Modified: 2013-11-05
I have two buttons on a form.  One of them opens a 2nd form in normal mode but I want the other button to open the same 2nd form in read-only mode.  The following is my onclick event code for opening the 2nd form in normal mode.  How do I alter it for the 2nd button to open the 2nd form in read-only mode?
-=-=-=-=-
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmJobCards"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command145_Click:
    Exit Sub

Err_Command145_Click:
    MsgBox Err.Description
    Resume Exit_Command145_Click
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Open the form in Design view
Double-click the form selector
In the AllowEdits property box, click No.
In the AllowDeletions property box, click No.
In the AllowAdditions property box, click No.
That should do it.

 
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Or you can set them in code. After opening your form, do this:

with Forms("frmCardJobs")
  .AllowAdditions=False
  .AllowEdits=False
  .AllowDeletions= False
End With
CERTIFIED EXPERT

Commented:
Or you could use the code for the on_load property Open property
Form.AllowAdditions = False

Author

Commented:
I don't think any of the recommendations so far will work.. Remember, I have just one form which when opened with button #1, allows for editing.  When the user clicks button #1, the same form has to open in read-only mode,
CERTIFIED EXPERT

Commented:
So who edits it then if it's not a user?
 
CERTIFIED EXPERT

Commented:
You could add another button and hide it. Or put a tiny button somewhere discreet on the form (make it transparent) and when clicked code the button that to show in edit mode, enter a password that you can set. Probably a better way to do this but I don't know if the users can get to the code, if not, then a password to edit mode would do.

Author

Commented:
The ability to get to the editable form is via a password form.  The read-only version has to be opened without going through a password form.
Scott McDaniel (EE MVE )Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
<When the user clicks button #1, the same form has to open in read-only mode,>

The suggestions we've made will result in a readonly form, assuming the form is not already opened. If it is, then my suggestion should work to set the form's properties dynamically ...
CERTIFIED EXPERT
Top Expert 2008

Commented:
For the command button you are clicking to open the form in read-only mode use the following code
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
CERTIFIED EXPERT

Commented:
"I have just one form which when opened with button #1, allows for editing.  When the user clicks button #1, the same form has to open in read-only mode".
I gave a solution to add a password form after giving a solution to make a form read-only!
"The ability to get to the editable form is via a password form.  The read-only version has to be opened without going through a password form."
Well I'd say any of the solutions provied will do what you want it to. Maybe have 2 buttons one saying "administrator settings" and one saying "Read data"?
You can't do things with one control unless it's triggered by an event, so you either have to have 2 buttons or 2 forms. There's no alternative.
Hope that helps a bit
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.