Re: Problem with SetFocus

Tech-Archive recommends: Fix windows errors by optimizing your registry



"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)


.



Relevant Pages

  • Re: How to suppress the "no current record" error.
    ... is about your form and subform that makes this error message popup. ... forms are setup that will stop that silly error message from popping up. ... Starting with a new form subform setup where that silly message does not ... viewing a permit which has a recordset for audits, ...
    (microsoft.public.access.formscoding)
  • RE: Error 2455 (associated with subform reference)
    ... The form is a purchase order form, and the subform ... lock some of the controls by looping through them. ... I have checked references, compacted the database, decomplied with a command ... could probably pass over the error message in the code's error handling, ...
    (microsoft.public.access.formscoding)
  • Re: Unexplained label behavior
    ... > "Dave the wave" wrote in message ... >> The error message is: ... >> subform, ... >>>> set the labels to the text box values and figured the problem was ...
    (microsoft.public.access.formscoding)
  • Re: Where do I put the code main or subform?
    ... click on the Next button of the built-in Access navigaton (on the subform), ... navigation of the subform again, this time, it is advanced to the next ... the error message pops up and I click the OK button of the ...
    (microsoft.public.access.formscoding)
  • RE: Crosstab Query Subform - Criteria from Combo Box on Main Form?
    ... "Duane Hookom" wrote: ... get an error message "Run-time error '3265'" Item not found in this ... subform, you don't actually have a subform - you have a field on the form ... Dim db As DAO.Database ...
    (microsoft.public.access.formscoding)