Combo Box to filter and Allow Edits (1 Viewer)

jamesave

New member
Local time
Today, 03:26
Joined
Apr 26, 2020
Messages
25
In Northwind DB frmProductDetail, I try to make the user unable to Edit the data by putting me.allowEdits = False when the form is open

Private Sub Form_Open(Cancel As Integer)
Me.AllowEdits = False
End Sub


This make the combo box cboFindProduct unselectable in form view. What is the best work around so the user can select a field from this combo box but the form still restrict the user from editing?
 
Cycle through the controls on that form and set to Locked to True or Enabled to False.?
If you are going to do this for more than one form, create a function ro enable/disable the controls and pass in the form as an object, and which way to amend.
 
Noted. Thanks for the input! I just create a cmdbutton to toggle for the Edit. It should at least will not allow the user to accidentally edit the values. There should be better way to implement, but it works for now.
 
You could also use it as a subform, and have your form with the search combo?
Probably a better way is to Enable Edits on GotFocus/Enter and Disable Edits on exit of that control?
Then you would need a button to allow Edits and then disable it again?
 
There should be better way to implement, but it works for now.
There are better ways. One very simple way is to have a button to toggle an internal variable to allow/not allow edits. Set the value to False in the Current event. Check the value in the On Dirty event. If it is still false, undo the edit and give the user a message to press the button if he wants to edit. Then in the AfterUpdate event of the form, set the value back to False. This allows all controls to be usable but the form will not allow edits unless the user has pressed the "allow" button.

Also, don't forget your validation code in the form's BeforeUpdate event. It is usually a lack of proper validation that causes developers to worry about this so make sure you don't allow bad data to be entered.
 

Users who are viewing this thread

Back
Top Bottom