Switch Between View and Edit Mode (1 Viewer)

yus786

I do OK
Local time
Today, 11:50
Joined
Jun 25, 2008
Messages
121
Hi again

I have a form with say contact details.

When the users opens this form - it needs to be in VIEW mode only. I then need a button that will switch all fields to EDIT mode

Is this at all possible? and if so how?
 
Well, one way I can think of would be to have two buttons: one for view mode and one for edit. You could stack them if you wish and change their "Visible" properties according to which mode the user is in (cmdButton.Visible = True/False). Then in the VBA Code you can register their "On Click" events to make all of you fields either Locked/Unlocked (txtBox.Locked = True/False) or disabled/enabled (txtBox.Enabled = True/False). To keep the box from being greyed out, disabled and lock the box. You would have to change these properties on each of your text boxes.

There may be an easier way to go about this, but I'm just throwing this out there.
 
Use form level properties

Hi

An easier way is to use following properties

Me.Form.AllowEdits=False 'locks editing on the whole form
Me.Form.AllowEdits=True 'Unlocks editing on the whole form

Few of the other properties you might want to consider

Me.Form.AllowAdditions=True/False
Me.Form.AllowDeletions=True/False

Hope it helps
 
THanks folks.

These properties changes you've mentioned - where is that done then?

I'm a novice and generally use the 'wizard' for everything.
 
I believe the method mentioned by agif can be done through the following:

Go to the form design view, then right-click in the grey box in the upper left corner where the vert. and horiz. rulers meet and select properties. This should open the form properties window. If a window goes away, repeat the step to bring it back. In the form properties window, click the event tab. Scroll down in that box until you find the "On Load" event, click in the text box next to it, then click the ellipsis (sp?) button. Select Code Builder and click OK. You should then be in the VBA coding environment. Once here, type in "Me.Form.AllowEdits=False" (without quotes). That should be all for the form. Save and close the VBA window (its separate from Access, so you won't close Access when you close the coding window).

Similarly for your command button, go back to design view for the form. If the properties window isn't open, right click your button that you plan to use to enable editing and click properties. Go to the event tab and find the "On Click" event, click in the text box next to it, click the ellipsis button, choose code builder and click OK. You should be back in the VBA coding environment again. All you should need to do is type "Me.Form.AllowEdits = True" (without quotes). After this feel free to actually open your form and text it out to see if it works.

Hopefully from here you can understand how to write the code to another button to disable the fields if you choose to put one in! And sorry for the long post, but I'm hoping this will be thorough enough to answer any questions you may have about where to go.
 
Thanks dapfeifer

You've been a great help. I've got most of it to work - just need to work out how to make it 'uneditable' again

Thanks again
 
In the AfterUpdate event of the form, set the allowedits property back to No.
 

Users who are viewing this thread

Back
Top Bottom