SteveL13
asked on
How open form in read only mode
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
-=-=-=-=-
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
Or you can set them in code. After opening your form, do this:
with Forms("frmCardJobs")
.AllowAdditions=False
.AllowEdits=False
.AllowDeletions= False
End With
with Forms("frmCardJobs")
.AllowAdditions=False
.AllowEdits=False
.AllowDeletions= False
End With
Or you could use the code for the on_load property Open property
Form.AllowAdditions = False
Form.AllowAdditions = False
ASKER
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,
So who edits it then if it's not a user?
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.
ASKER
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.
<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 ...
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 ...
For the command button you are clicking to open the form in read-only mode use the following code
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly
"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
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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.