First of all thanks for your videos,they are amazing.
I seem to have ran into a problem and cant find a solution anywhere and have tried various solutions.
I used your video on creating edit button as I want to prevent accidental changes to info however the form I have used it on has 2 combo boxes in the header which can be filtered to 'individual' name. But due to setting me.allowedits to false, I cannot filter the form unless I go into edit mode which is not ideal.
So what I am trying to achieve is to be able to filter the form from combo box without going into edit mode but keep all other fields locked from editing whilst I filter?
Your help would be much appreciated.
Thank you
Kevin Robertson
@Reply 3 years ago
Instead of setting Allow Edits to false I would loop through all the controls (exclude labels, button and any controls on your form that don't have a Locked property) in the Detail section and set the Locked property of each control to False.
Kevin Robertson
@Reply 3 years ago
Here is some sample code:
Set the Locked property to True (you will need a second loop to set it to False) Dim Ctrl as Control
For Each Ctrl In Me.Section(0).Controls
If Ctrl.ControlType <> acLabel And Ctrl.ControlType <> acCommandButton then
Ctrl.Locked = True
End If
Next
.../
Toggle the Locked property between True and False Dim Ctrl As Control
For Each Ctrl In Me.Section(0).Controls
If Ctrl.ControlType <> acLabel And Ctrl.ControlType <> acCommandButton Then
Ctrl.Locked = Not Ctrl.Locked
End If
Next
.../
Toggle the Locked property between True and False, change the caption of the button Dim Ctrl As Control
For Each Ctrl In Me.Section(0).Controls
If Ctrl.ControlType <> acLabel And Ctrl.ControlType <> acCommandButton Then
Ctrl.Locked = Not Ctrl.Locked
If Ctrl.Locked Then
YourButtonName.Caption = "Edit"
Else
YourButtonName.Caption = "Save"
End If
End If
Next
Kevin Yip
@Reply 3 years ago
Another way is to put the non-editable fields in a subform with AllowEdits set to false, and the combo boxes on the main form with AllowEdits true. The VBA code for filtering will be different in a mainform-subform setup, however.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Visitor Forum.