set focus enabled

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

As a beginner I am aware I amy not dis/enable a control that has focus. So I
move focus before the attempt.

I have [MainForm], [Sub1] and [Sub2].

I wish to disable a control on [Sub2] from the current event of [Sub1].

I get the message 2164 that I cannot disable a control that has focus.

My code is:
'DISABLED
Me!holdfocus.SetFocus (or Me.Parent.holdfocus.SetFocus
Me!BCfrm.Form!SVisitFrame.Enabled = False

What gives? Any suggestions or stupidity alerts are greatly appreciated!
 
While not obvious, there's actually separate Focus for forms and subforms.
Try setting the focus to another control on the same subform.
 
Thanks for responding. No joy!

Error 2110 cannot move the focus. Why not?

--
Thanks for your help,
Chris


Douglas J. Steele said:
While not obvious, there's actually separate Focus for forms and subforms.
Try setting the focus to another control on the same subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris said:
As a beginner I am aware I amy not dis/enable a control that has focus.
So I
move focus before the attempt.

I have [MainForm], [Sub1] and [Sub2].

I wish to disable a control on [Sub2] from the current event of [Sub1].

I get the message 2164 that I cannot disable a control that has focus.

My code is:
'DISABLED
Me!holdfocus.SetFocus (or Me.Parent.holdfocus.SetFocus
Me!BCfrm.Form!SVisitFrame.Enabled = False

What gives? Any suggestions or stupidity alerts are greatly appreciated!
 
Works fine in a test for me just now.

What's the actual code you're using (and where is it running: on the parent
or the subform)?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris said:
Thanks for responding. No joy!

Error 2110 cannot move the focus. Why not?

--
Thanks for your help,
Chris


Douglas J. Steele said:
While not obvious, there's actually separate Focus for forms and
subforms.
Try setting the focus to another control on the same subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris said:
As a beginner I am aware I amy not dis/enable a control that has focus.
So I
move focus before the attempt.

I have [MainForm], [Sub1] and [Sub2].

I wish to disable a control on [Sub2] from the current event of [Sub1].

I get the message 2164 that I cannot disable a control that has focus.

My code is:
'DISABLED
Me!holdfocus.SetFocus (or Me.Parent.holdfocus.SetFocus
Me!BCfrm.Form!SVisitFrame.Enabled = False

What gives? Any suggestions or stupidity alerts are greatly
appreciated!
 
Yeah, works for me too in a "clean" procedure. I can probably live with only
locked/unlocked, that works fine.

The code is in the curren event of [Sub1] trying to disable a control on
[Sub2].
--
Thanks for your help, code follows.
Chris


onCurrent code: ******************************
Private Sub Form_Current()
'ALERT NOTE FLASH if NOT EMPTY
If Not IsNull(Me.txtAlertNote.Value) Then
Me.lblNAAlert.Visible = False
Me.txtAlertNote.BackColor = 16777215
Me.Box13.BorderColor = 5513182
Me.txtAlertNote.BorderColor = 5513182
ElseIf IsNull(Me.txtAlertNote.Value) Then
Me.lblNAAlert.Visible = True
Me.txtAlertNote.BackColor = -2147483633
Me.Box13.BorderColor = 11711154
Me.txtAlertNote.BorderColor = 11711154
End If

'DISPLAYS CANCELLED MESSAGE FOR CANCELLED JOB
If Me.ckCancelled = True Then
Me.lblCancelled.Visible = True
Me.txtInvNum.Width = 960
Else
Me.lblCancelled.Visible = False
Me.txtInvNum.Width = 1080
End If

'SETS VISITS PAGE PER SERVICE
If Me.cboService = "at your Bark & Call" Then
Me.BCfrm.Visible = True
Me.BBfrm.Visible = False
Me.HSfrm.Visible = False
Me.POfrm.Visible = False
Me.DCfrm.Visible = False
Me.OSfrm.Visible = False
ElseIf Me.cboService = "Bed & Biscuit" Then
Me.BCfrm.Visible = False
Me.BBfrm.Visible = True
Me.HSfrm.Visible = False
Me.POfrm.Visible = False
Me.DCfrm.Visible = False
Me.OSfrm.Visible = False
ElseIf Me.cboService = "HouseSitting" Then
Me.BCfrm.Visible = False
Me.BBfrm.Visible = False
Me.HSfrm.Visible = True
Me.POfrm.Visible = False
Me.DCfrm.Visible = False
Me.OSfrm.Visible = False
ElseIf Me.cboService = "DayCare" Then
Me.BCfrm.Visible = False
Me.BBfrm.Visible = False
Me.HSfrm.Visible = False
Me.POfrm.Visible = False
Me.DCfrm.Visible = True
Me.OSfrm.Visible = False
ElseIf Me.cboService = "All Pooped Out?" Then
Me.BCfrm.Visible = False
Me.BBfrm.Visible = False
Me.HSfrm.Visible = False
Me.POfrm.Visible = True
Me.DCfrm.Visible = False
Me.OSfrm.Visible = False
ElseIf Me.cboService = "Other Services" Then
Me.BCfrm.Visible = False
Me.BBfrm.Visible = False
Me.HSfrm.Visible = False
Me.POfrm.Visible = False
Me.DCfrm.Visible = False
Me.OSfrm.Visible = True
End If
'SET FIELD FOR NON-EDIT
*************************************************************************************************** JOB FORM
'JOB FORM
'BORDER (only on leaving edit)
Me.txtAlertNote.BorderColor = 11711154
Me.cboService.BorderColor = 11711154
Me.txtStartDate.BorderColor = 11711154
Me.txtEndDate.BorderColor = 11711154
Me.txtDogCount.BorderColor = 11711154
Me.txtOtherCount.BorderColor = 11711154
Me.txtPmtType.BorderColor = 11711154
Me.txtCoupon.BorderColor = 11711154
Me.txtDepositRequired.BorderColor = 11711154
'BACKGROUND
Me.txtAlertNote.BackColor = -2147483633
Me.lblNAAlert.Visible = False
Me.cboService.BackColor = -2147483633
Me.txtStartDate.BackColor = -2147483633
Me.txtEndDate.BackColor = -2147483633
Me.txtDogCount.BackColor = -2147483633
Me.txtOtherCount.BackColor = -2147483633
Me.txtPmtType.BackColor = -2147483633
Me.txtCoupon.BackColor = -2147483633
Me.txtDepositRequired.BackColor = -2147483633
'SUNKEN
Me.txtAlertNote.SpecialEffect = 0
Me.cboService.SpecialEffect = 0
Me.txtStartDate.SpecialEffect = 0
Me.txtEndDate.SpecialEffect = 0
Me.txtDogCount.SpecialEffect = 0
Me.txtOtherCount.SpecialEffect = 0
Me.txtPmtType.SpecialEffect = 0
Me.txtCoupon.SpecialEffect = 0
Me.txtDepositRequired.SpecialEffect = 0
'UNLOCKED
Me.txtAlertNote.Locked = True
Me.cboService.Locked = True
Me.txtStartDate.Locked = True
Me.txtEndDate.Locked = True
Me.txtDogCount.Locked = True
Me.txtOtherCount.Locked = True
Me.txtPmtType.Locked = True
Me.txtCoupon.Locked = True
Me.txtDepositRequired.Locked = True
'SET TO ENABLED
Me.txtAlertNote.Enabled = False
Me.cboService.Enabled = False
Me.txtStartDate.Enabled = False
Me.txtEndDate.Enabled = False
Me.txtDogCount.Enabled = False
Me.txtOtherCount.Enabled = False
Me.txtPmtType.Enabled = False
Me.txtCoupon.Enabled = False
Me.txtDepositRequired.Enabled = False
'JOB VISITS --BC FORM
****************************************************************************************************** BC
'SUNKEN
Me!BCfrm.Form!SVisitFrame.SpecialEffect = 0
Me!BCfrm.Form!DVisitFrame.SpecialEffect = 0
Me!BCfrm.Form!EVisitFrame.SpecialEffect = 0
Me!BCfrm.Form!EODframe.SpecialEffect = 0
'BACKGROUND
Me!BCfrm.Form!SVisitFrame.BackColor = -2147483633
Me!BCfrm.Form!lblSVisit.BackColor = -2147483633
Me!BCfrm.Form!lblSVisAM.BackColor = -2147483633
Me!BCfrm.Form!lblSVisMid.BackColor = -2147483633
Me!BCfrm.Form!lblSVisPM.BackColor = -2147483633
Me!BCfrm.Form!lblSVisAMPM.BackColor = -2147483633
Me!BCfrm.Form!lblSVisAMMid.BackColor = -2147483633
Me!BCfrm.Form!lblSVisMidPM.BackColor = -2147483633
Me!BCfrm.Form!lblSVisAMMidPM.BackColor = -2147483633
Me!BCfrm.Form!DVisitFrame.BackColor = -2147483633
Me!BCfrm.Form!lblDVisit.BackColor = -2147483633
Me!BCfrm.Form!lblDVisAM.BackColor = -2147483633
Me!BCfrm.Form!lblDVisMid.BackColor = -2147483633
Me!BCfrm.Form!lblDVisPM.BackColor = -2147483633
Me!BCfrm.Form!lblDVisAMPM.BackColor = -2147483633
Me!BCfrm.Form!lblDVisAMMID.BackColor = -2147483633
Me!BCfrm.Form!lblDVisMidPM.BackColor = -2147483633
Me!BCfrm.Form!lblDVisAMMidPM.BackColor = -2147483633
Me!BCfrm.Form!EVisitFrame.BackColor = -2147483633
Me!BCfrm.Form!lblEVisit.BackColor = -2147483633
Me!BCfrm.Form!lblEVisAM.BackColor = -2147483633
Me!BCfrm.Form!lblEVisMid.BackColor = -2147483633
Me!BCfrm.Form!lblEVisPM.BackColor = -2147483633
Me!BCfrm.Form!lblEVisAMPM.BackColor = -2147483633
Me!BCfrm.Form!lblEVisAMMid.BackColor = -2147483633
Me!BCfrm.Form!lblEVisMidPM.BackColor = -2147483633
Me!BCfrm.Form!lblEVisAMMidPM.BackColor = -2147483633
Me!BCfrm.Form!lbleodVisits.BackColor = -2147483633
Me!BCfrm.Form!lbleodAM.BackColor = -2147483633
Me!BCfrm.Form!lbleodMid.BackColor = -2147483633
Me!BCfrm.Form!lbleodPM.BackColor = -2147483633
Me!BCfrm.Form!lblModifyVisits.BackColor = -2147483633
Me!BCfrm.Form!lblAdditions.BackColor = -2147483633
Me!BCfrm.Form!lblExceptions.BackColor = -2147483633
Me!BCfrm.Form!EODframe.BackColor = -2147483633
Me!BCfrm.Form!lbleodAM.BackColor = -2147483633
Me!BCfrm.Form!lbleodMid.BackColor = -2147483633
Me!BCfrm.Form!lbleodPM.BackColor = -2147483633
'LOCKED
Me!BCfrm.Form!SVisitFrame.Locked = True
Me!BCfrm.Form!DVisitFrame.Locked = True
Me!BCfrm.Form!EVisitFrame.Locked = True
Me!BCfrm.Form!EODframe.Locked = True
'DISABLED
'Me.txtCoupon.SetFocus
'Me!BCfrm.Form!SVisitFrame.Enabled = False
'Me!BCfrm.Form!DVisitFrame.Enabled = False
'Me!BCfrm.Form!EVisitFrame.Enabled = False
'Me!BCfrm.Form!EODframe.Enabled = False
'Me!BCfrm.Form!btnAdditions.Enabled = False
'Me!BCfrm.Form!btnExceptions.Enabled = False
End Sub

end code *******************************************



Douglas J. Steele said:
Works fine in a test for me just now.

What's the actual code you're using (and where is it running: on the parent
or the subform)?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Chris said:
Thanks for responding. No joy!

Error 2110 cannot move the focus. Why not?

--
Thanks for your help,
Chris


Douglas J. Steele said:
While not obvious, there's actually separate Focus for forms and
subforms.
Try setting the focus to another control on the same subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


As a beginner I am aware I amy not dis/enable a control that has focus.
So I
move focus before the attempt.

I have [MainForm], [Sub1] and [Sub2].

I wish to disable a control on [Sub2] from the current event of [Sub1].

I get the message 2164 that I cannot disable a control that has focus.

My code is:
'DISABLED
Me!holdfocus.SetFocus (or Me.Parent.holdfocus.SetFocus
Me!BCfrm.Form!SVisitFrame.Enabled = False

What gives? Any suggestions or stupidity alerts are greatly
appreciated!
 
Back
Top