HI
I have 2 subforms on a main form. All the controls on the subforms are locked and disabled by Default.
I want to have an "Edit" command button on the main form to unlock and enable the controls on the subform.
I have the following code for the cmdEdit:
Everything works great except that when a control on either of the subforms has the focus, it is not possible to relock and disable the controls with cmdEdit.
Is there a way to lose focus on these controls when the cmdEdit button is pressed? Thanks!
I have 2 subforms on a main form. All the controls on the subforms are locked and disabled by Default.
I want to have an "Edit" command button on the main form to unlock and enable the controls on the subform.
I have the following code for the cmdEdit:
Code:
Private Sub cmdEdit_Click()
On Error GoTo Err_cmdEdit_Click
Dim C As Variant
If cmdEdit.Caption = "Edit" Then
For Each C In Me![frmJobPrices].Controls
If Right(C.Name, 5) = "price" Then
C.BorderStyle = 1
C.Locked = False
C.Enabled = True
End If
Next C
For Each C In Me![frmMoreInfo2].Controls
If Left(C.Name, 6) = "txtmov" Then
C.BorderStyle = 1
C.Locked = False
C.Enabled = True
End If
Next C
Me![frmMoreInfo2]![txtSystemPrice].BorderStyle = 1
Me![frmMoreInfo2]![txtSystemPrice].Locked = False
Me![frmMoreInfo2]![txtSystemPrice].Enabled = True
cmdEdit.Caption = "Submit"
Else
For Each C In Me![frmJobPrices].Controls
If Right(C.Name, 5) = "price" Then
C.BorderStyle = 0
C.Locked = True
C.Enabled = False
End If
Next C
For Each C In Me![frmMoreInfo2].Controls
If Left(C.Name, 6) = "txtmov" Then
C.BorderStyle = 0
C.Locked = True
C.Enabled = False
End If
Next C
Me![frmMoreInfo2]![txtSystemPrice].BorderStyle = 0
Me![frmMoreInfo2]![txtSystemPrice].Locked = True
Me![frmMoreInfo2]![txtSystemPrice].Enabled = False
cmdEdit.Caption = "Edit"
End If
Exit_cmdEdit_Click:
Exit Sub
Err_cmdEdit_Click:
MsgBox Err.Description
Resume Exit_cmdEdit_Click
End Sub
Everything works great except that when a control on either of the subforms has the focus, it is not possible to relock and disable the controls with cmdEdit.
Is there a way to lose focus on these controls when the cmdEdit button is pressed? Thanks!