RE: Problem with SetFocus



If that works, I have an idea why

Regards Mike B
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


"MikeJohnB" wrote:

Just a thought, have you tried setting focus to the form first as:

Forms!NameAndAddress.SetFocus
Forms!NameAndAddress.Repaint
Forms!NameAndAddress.SetFocus
Forms!NameAndAddress![Post Code].SetFocus

I dont get an error when I use the last two lines but I don't use the
repaint method.

I have noticed I have used DoCmd to overcome one issue the same as yours

DoCmd.SetWarnings False
DoCmd.GoToControl "ProjectPlan"
DoCmd.SetWarnings True

I can't remember why I used this though and most of the time,

Forms!FormName.SetFocus
Forms!FormName![Post Code].SetFocus

Appears to work for me?? Let know if you find the error?

Mike B
--
An Engineers Prayer:
At the very end of the day,
when all else fails,
you have tried all,
you have shouted at and blamed the innocent,
and asked everyone you know,

READ THE INSTRUCTION MANUAL.


"OssieMac" wrote:

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]

Will very much appreciate any help.

Regards,

OssieMac

.



Relevant Pages

  • Re: Decimal fieldss precision is too small to accept the numeric you attempted to add
    ... I don't know the Scale and Precision of your Decimal fields, ... case something is actually overflowing (as the error message suggests). ... both of those, still fails. ...
    (microsoft.public.access.queries)
  • Re: Unparsable Record
    ... I tried simply importing 1 column - deleting all the rest. ... Method 'ExecuteTempImexSpec' of object '_WizHook' failed error message. ... If that fails, delete 11 more columns so only the first 11 ... importing the first column - skipping all the other columns, ...
    (microsoft.public.access.externaldata)
  • Re: Permanently Disabling Content Advisor
    ... If that fails, post the exact error message to a newsgroup about IE. ...
    (microsoft.public.security)
  • Re: Closing Form Produces "Runtime Error 2585"
    ... My main concern is that you should NEVER store an easily calculatable entity ... calculated field to give you the Full Name from its component parts as and ... > I'm getting the above referenced error (error message: ... DoCmd, it still fails. ...
    (microsoft.public.access.formscoding)
  • Re: Wizard
    ... "MikeJohnB" wrote: ... An Engineers Prayer: ... when all else fails, ... "Rick B" wrote: ...
    (microsoft.public.access.gettingstarted)