Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Focus to a control on the main form

Status
Not open for further replies.

gtob5

Technical User
Mar 16, 2009
4
US
I have a list of account no's on a subform.
I am trying to use a doubleclick on the list to change the value in a combo box on the main form and start some code in the got focus event for the main combobox.

I get a '2110' error (cannot move focus to control) when I try to set focus on cboAccountNo. The control is visible and enabled.
If I debug and press F8, no problem.

Private sub lstNoStatus_DblClick(Cancel as Integer)
Forms!frmCaseEntry.cboAccountNo.Value = lstNoStatus.Value
Forms![frm_CaseEntry].SetFocus
Forms![frm_CaseEntry]![cboAccountNo].SetFocus
end sub

The value of cboAccountNo changes as desired.
The error shows up after the got focus code runs. I have a msgbox in the got focus code.

 
Code:
Private sub lstNoStatus_DblClick(Cancel as Integer)
Forms!frmCaseEntry.cboAccountNo.Value = lstNoStatus.Value

call cboAccountNo_gotfocus

end sub

The proceedure for cboAccountNo_gotfocus needs to be changed from private to public.

This will call the sub then return to the above sub after running it.

Quite a complex way to approach it! I suggest you look at what you are trying to do and approach it in a different way.

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
I have changed cboAccountNo_GotFocus to public and inserted the call. I now get a compile error "Sub or Function not defined" for call cboAccountNo_GotFocus().
 
Got it working by using
Forms!frm_CaseEntry.cboAccountNo_GotFocus
instead of Call cboAccountNo_GotFocus

Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top