MS Access Forum / Forms / May 2008
Opening form for viewing only
|
|
Thread rating:  |
Names - 21 May 2008 10:41 GMT Hi,
How does one prevent a form from being changed? I am trying to have the form open for confirmation purposes, but opening in print preview mode is not quite what I have in mind.
I tried using a macro, setting the data mode argument to "Read only", but when I open the supposedly "Read only" form, I am still able to change the information stored in the fields. I also tried setting "Allow edits", in the property sheet of the form, to "no". However, the same problem occured and information in the opened form could still be changed. But setting "Allow additions" to "no" works (in preventing addtional entries). What should I do?
Thanks in advance!
George - 21 May 2008 11:12 GMT I have tried AllowEdits - No, using Access 2003 and is OK with me. What type of form are you using and what ver. of Access?
Ο χρήστης "Names" έγγραψε:
> Hi, > [quoted text clipped - 10 lines] > > Thanks in advance! Names - 21 May 2008 17:28 GMT Thanks for the reply. I'm using Access 2003. The form is quite an ordinary form. It is based on a query that filters records according to ClassificationID, so that when a user clicks on a button in the subform of the main data entry form, the relevant form is opened, with only the records under that classification.
I am trying to make it such that the information in this second form that opens cannot be changed by the user, but I have not had much success on this, and have only managed to prevent the adding of new records, using Allow Additions - no.
Thanks so much for your time!
> I have tried AllowEdits - No, using Access 2003 and is OK with me. What type > of form are you using and what ver. of Access? Jeff Garrison - 21 May 2008 18:29 GMT Have you tried Locking the fields?
> Thanks for the reply. I'm using Access 2003. The form is quite an ordinary > form. It is based on a query that filters records according to [quoted text clipped - 14 lines] >> type >> of form are you using and what ver. of Access? Names - 22 May 2008 02:24 GMT Great! I hadn't tried locking the fields, thanks a lot for the advice. It's working now, after a quick search in the Help for "Lock fields" after reading the posts, and discovering it was under properties, for the textbox controls of the relevant fields..
Thank you!
> Have you tried Locking the fields? > [quoted text clipped - 16 lines] > >> type > >> of form are you using and what ver. of Access? Linq Adams - 22 May 2008 03:02 GMT Opening the form using the simple line
DoCmd.OpenForm "YourFormName", , , , acFormReadOnly
should open any form in Read Only Mode, regardless of what the particular form's properties are set on.
 Signature There's ALWAYS more than one way to skin a cat!
Answers/posts based on Access 2000/2003
Names - 22 May 2008 04:20 GMT Thanks for helping,
I typed in the following code, because I'm also trying to get different forms to open depending on what is entered in another field (Category).
Private Sub MainformRunOpenCatForm_Click() DoCmd.OpenForm "=[Forms]![MainFormName]![SubformName]![FieldName].[Value]", , , , acFormReadOnly End Sub
I was still able to type into the form that opened, and could change the data there. So I tried what you had suggested:
Private Sub MainformRunOpenCatForm_Click() DoCmd.OpenForm "FormName", , , , acFormReadOnly End Sub
But like what happened above, changes could be made to the data.. This Read only method does seem suitable, though. Because it seems that if I lock the fields I might need to have a separate form for editting entries as opening the form (elsewhere) in edit mode through a macro does not seem to override having locked the fields. Is this true? I tried to get the locked form to open in edit mode but the fields remained locked.
Thanks for all the help. Regards
> Opening the form using the simple line > > DoCmd.OpenForm "YourFormName", , , , acFormReadOnly > > should open any form in Read Only Mode, regardless of what the particular > form's properties are set on. Linq Adams - 22 May 2008 04:47 GMT >Private Sub MainformRunOpenCatForm_Click() > DoCmd.OpenForm >"=[Forms]![MainFormName]![SubformName]![FieldName].[Value]", , , , >acFormReadOnly >End Sub makes no sense at all!
"=[Forms]![MainFormName]![SubformName]![FieldName].[Value]"
is not a valid value! To use a textbox value as the file name to open, you need to do something like
Private Sub MainformRunOpenCatForm_Click()
FormToOpen =Forms![MainFormName]![SubformName]![FieldName].[Value]
DoCmd.OpenForm FormToOpen , , , , acFormReadOnly
End Sub
assuming that
Forms![MainFormName]![SubformName]![FieldName].[Value]
is the correct sytax to refer to the textbox on the subform. I'm not at a PC that has Access installed right now, and deldom use subforms, so I can't be sure that the syntax is correct, but try it.
 Signature There's ALWAYS more than one way to skin a cat!
Answers/posts based on Access 2000/2003
Names - 22 May 2008 06:25 GMT Thanks.. Sorry I don't know much about code. Somehow both versions seem to be doing the same thing so far; I've changed it according to your suggestion. Here is the exact code I have used:
Private Sub MainformRunOpenCatForm_Click() FormToOpen = Forms![Mainform]![Subform3]![Category].[Value] DoCmd.OpenForm FormToOpen, , , , acFormReadOnly End Sub
When the form opens, still the entries can be changed, the Read only part doesn't seem to be working. I'm quite puzzled.
Thanks again for your time!
> >Private Sub MainformRunOpenCatForm_Click() > > DoCmd.OpenForm [quoted text clipped - 24 lines] > that has Access installed right now, and deldom use subforms, so I can't be > sure that the syntax is correct, but try it. Names - 23 May 2008 02:50 GMT Hi Jeff,
Is it possible to override the setting of locking fields? For e.g. having a macro which would open the form in edit mode is supposed to override the setting of "Allow Edits = No". I tried this method to override the locking of fields but to no avail..
> Have you tried Locking the fields? Names - 27 May 2008 04:23 GMT Hi all,
I accidentally found that when I don't use a certain macro on the form, it can be opened "read-only". This particular macro is a "set value" macro that is attached to the "on current" event of the form. I have been using it to set the value of a certain field whenever the form opens, but when it is supposed to be "read-only", I actually don't need it as only existing records would be viewed. So in case anyone is facing a similar problem this might be why.
Thanks for all the help! Regards.
|
|
|