Re: Problem with SetFocus
- From: "Dirk Goldgar" <dg@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 26 Feb 2007 21:47:25 -0500
"OssieMac" <OssieMac@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:045FEFDC-E742-45F8-9F77-9D6CE98E0E9C@xxxxxxxxxxxxx
I am using Access 2002. I have considerable experience with Excel and
VBA but very little with Access.
My problem is with SetFocus. I have a main form and a subform. I
shift the focus to the subform and after some processing I am trying
to set the focus back to a control on the main form. However, I get
an error 2110. (Microsoft Access can't move the focus to this
control.)
After considerable testing, the SetFocus appeared to be working even
though I was still getting the error message.
I tried OnError Resume Next to suppress the Error message and now it
works fine. However, I would like to know if anyone can give me any
advice. Perhaps I should be including some other code first.
This is the code. (I have tried with and without the first 3 lines
and they make no difference.)
Forms!NameAndAddress.Visible = True
Forms!NameAndAddress.SetFocus
Forms!NameAndAddress.Repaint
On Error Resume Next
Forms!NameAndAddress![Post Code].SetFocus
On Error GoTo 0
Have also tried the following without success using both with and
without the error message suppressing. Doesn't work with either
method.
Forms!NameAndAddress.Visible = True
Forms!NameAndAddress.SetFocus
Forms!NameAndAddress.Repaint
DoCmd.GoToControl [Post Code]
In what event are you executing this code? You say you shift the focus
to the subform, do some processing, and then are trying to set it back
to the main form. Do you mean you are doing all that in one procedure,
or is that just a rough summary of the sequence of operations?
Normally, I'd expect a simple
Me.Parent![Post Code].SetFocus
(executed from the subform) to work. Could you explain a bit more about
exactly what your code is doing? What is the actual sequence of events?
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
.
- Follow-Ups:
- Re: Problem with SetFocus
- From: OssieMac
- Re: Problem with SetFocus
- Prev by Date: Re: Date() function
- Next by Date: Re: Problem with SetFocus
- Previous by thread: RE: Problem with SetFocus
- Next by thread: Re: Problem with SetFocus
- Index(es):
Relevant Pages
|