Make a form uneditable until click edit button

Hi

I have created a form from a table now what i want is that it should be uneditable unit a user click a edit button.

So please tell me how to make a form uneditable and create a edit button.

Thanks

Amar
Answer
Answer

Open the form in design view.

Activate the Event tab of the Property Sheet.

Select [Event Procedure] from the dropdown in the On Current event.

Click the builder buttons ... to the right of the dropdown arrow.

Make the code look like this:

 

Private Sub Form_Current()
    Me.AllowEdits = Not Me.NewRecord
End Sub

 

This will disable editing when the user loads an existing record, New records can still be created and edited.

Switch back to the form in Access.

Place a command button on the form. Make sure that the command button is selected.

Activate the Format tab of the Property Sheet and set the Caption property to Edit Record or whatever you prefer.

Activate the Other tab of the Property Sheet and set the Name property to cmdEdit.

Activate the Event tab of the Property Sheet.

Select [Event Procedure] from the On Click event, then click the builder buttons ...

Make the code look like this:

 

Private Sub cmdEdit_Click()
    Me.AllowEdits = True
End Sub

---
Best wishes, HansV
https://www.eileenslounge.com

6 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Answer
Answer

If you want one control (or field) to be editable, you should NOT set AllowEdits to No, because that will lock the entire form.

Instead, work with the Locked property of the individual controls. If Locked = True, the user cannot edit the contents, and if Locked is False, the contents can be edited.

Set the Locked property of all text boxes, combo boxes, check boxes etc. to Yes in design view. Let's say that the combo box that you want to unlock is MyCombo. You can then use

 

Private Sub cmdEdit_Click()
    Me.AllowEdits = True
    Me.MySubform!MyCombo.Locked = True
End SubPrivate

Sub Form_Current()
    Me.AllowEdits = Me.NewRecord
    Me.MySubform!MyCombo.Locked = Me.NewRecord
End Sub

---
Best wishes, HansV
https://www.eileenslounge.com

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 1, 2024 Views 16,379 Applies to: