Open a Form in Read Only or Edit Mode.

skelley

Registered User.
Local time
Today, 13:06
Joined
Jul 11, 2000
Messages
69
Is there a way to have one (1) form open in either read only mode or edit mode? For the moment I have two (2) forms. One with the properties set to read only and the other not. Every time I make a change to one, I have to recreate the other by copying the first and changing the properties.
 
Open your form with code. Use the Data Mode argument of the DoCmd.Open form method:

This opens form in Add Mode:
DoCmd.OpenForm "YourFormName", , , , acFormAdd

This opens form in Read Only Mode:
DoCmd.OpenForm "YourFormName", , , , acFormReadOnly

This opens form in Edit Mode:
DoCmd.OpenForm "YourFormName", , , , acFormEdit

Replace "YourFormName" with the name of your form.

HTH
RDH
 
R. Hicks

Thx for response. I am using an Access Switchboard. Where do I put this code to work?
 
Unfortunately the switchboard only gives you the option of opening in edit view or add view. What I do to get around this is to write a public function that contains only the following line of code:

DoCmd.OpenForm "MyFormName", , , , acFormReadOnly

Then instead of selecting "open form in edit mode" from the switchboard manager, I choose "run code" and specify the appropriate function.
 
A function you write in a code module that is declared as public. The public declaration makes it available to any object in the entire database. Private functions are only available within the module in which they are defined.

Public Function YourFunction()
DoCmd.OpenForm "YourFormName", , , , acFormReadOnly
End Function
 
The above did not work from an Access Switchboard or I do not know how to code the "appropriate function" into the switchboard.

Please advise.
 
Choose the Run Code command and when you type your function name in the Function name box, follow it with open and close parens:

YourFunction()
 
Open your form with code. Use the Data Mode argument of the DoCmd.Open form method:

This opens form in Edit Mode:
DoCmd.OpenForm "YourFormName", , , , acFormEdit

Replace "YourFormName" with the name of your form.

HTH
RDH

The problem is that when you open a form with this method, you can edit and also add records.

I really like to know how to open with only the edit mode enabled and the add mode desabled.
Is this possible?
 

Users who are viewing this thread

Back
Top Bottom