smtazulislam
Member
- Local time
- Today, 17:56
- Joined
- Mar 27, 2020
- Messages
- 808
Private Sub EnableData()
txtEmployeeID.Enabled = True
txtEmployeeName.Enabled = True
alltxt.......=true
End Sub
Private Sub DisabledData()
txtEmployeeID.Enabled = False
txtEmployeeName.Enabled = False
alltxt.....=false
End Sub
tblStatus now I haveRather than writing code to group the status', I would add an additional column to the status table and use "enable" as the value for one of the groups and "disable" as the value for the other group. That way, if you need to add more status codes, you don't need to modify your code, you just add a new record to the status table.
But when form reopen then all data is enable again.
Apologies for late reply. Corona Virus effected in our business and shut down the all of the work up to 3 months, now we shifty start work..We waste our time AND YOURS by taking shots in the dark. Help us to help you.
Private Sub cboStatus_Change()
EnableControls False, "A"
End Sub
Now my Module is LIKE thatat frmEmployeeEdit
As far as I can see, the only place EnableControls is used is in this code which is called in the Form_Current event.
Code:Private Sub cboStatus_Change() EnableControls False, "A" End Sub
I suggest moving that code to cboStatus_AfterUpdate and removing the Call cboStatus_Change line from Form_Current as its unnecessary and may be causing issues
Public Sub EnableControls(State As Boolean, Tg1 As String, Optional Tg2 As String, Optional Tg3 As String, _
Optional Tg4 As String, Optional Tg5 As String, Optional Tg6 As String)
On Error GoTo Err_Handler
'set controls to locked or not according to the control tag value
For Each ctrl In Screen.ActiveForm.Controls
Select Case ctrl.ControlType
Case acLabel, _
acImage, _
acLine, _
acRectangle
'acPageBreak
'no code here - these can't be disabled
Case Else
If ctrl.Tag = Tg1 Or _
ctrl.Tag = Tg2 Or _
ctrl.Tag = Tg3 Or _
ctrl.Tag = Tg4 Or _
ctrl.Tag = Tg5 Or _
ctrl.Tag = Tg6 Then ctrl.Enabled = State
End Select
Next ctrl
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " in EnableControls procedure: " & Err.Description
Resume Exit_Handler
End Sub
Private Sub cboStatus_Change()
On Error GoTo Err_Handler
'Emable controls fields
EnableControls False, "A"
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " " & Err.Description
Resume Exit_Handler
End Sub
Private Sub Form_Current()
On Error GoTo Err_Form_Current
Call cboStatus_Change
Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub
Thanks for gave time to reply. In the my form have original code copy as same here vertical don't showed so I put Breaks line. Apologies for it.All you've done to the module code is add line breaks. Fine if you prefer that but functionally identical to the original code.
Thank you so much for gave times and many advised into this issued. I appreciate.OK. Please upload the latest version and I'll take a look but it won't be till tomorrow as its getting late here in the UK.
Public Sub EnableControls(State As Boolean, Tg1 As String, Optional Tg2 As String, Optional Tg3 As String, Optional Tg4 As String, Optional Tg5 As String, Optional Tg6 As String)
On Error GoTo Err_Handler
'set controls to locked or not according to the control tag value
For Each ctrl In Screen.ActiveForm.Controls
Debug.Print ctrl.ControlType, ctrl.Name, ctrl.Tag
Select Case ctrl.ControlType
....