Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    outside the rim

    Unanswered: GoToControl vs. SetFocus


    I have a form with a command button called "cmdPrint". For a long time, the line DoCmd.GoToControl ("cmdPrint") has moved the focus to that button flawlessly.

    Now, all of a sudden, it tells me "cmdPrint not found in the current record" (the button is enabled). If I go in and do a "reference update"* (long story) then it suddenly starts working again.

    Curiously, Me.cmdPrint.SetFocus still works, even if I don't do an update of references.

    What's the difference?

    *A reference update is where all of the references are fine, but you have to uncheck one and then go back and recheck it to "refresh" the references according to Microsoft.

  2. #2
    Join Date
    Jun 2002
    Saudi Arabia / Philippines

    I cannot explain why resetting the reference makes any difference or why it should suddenly start happening. However I stumble across similar things now and again. I have a number of suspects that may explain these sudden changes in behaviour.

    1. I recently loaded Microsoft Project v2000 (I use Office/Access 2002) and Project was one of the applications that got forgotten when the Techies upgraded my laptop from XP Home to XP Professional. Following that my Access applications went wild for a while, particularly the Calendar Control that I had to remove and reload. So does loading new or upgraded Microsoft software disturb existing libraties? It must have some effect.

    2. We are all encouraged to keep our systems up-to-date with the latest patches, particularly the critical updates. Do these disturb the libraries referenced by Access?

    3. Believe me when I say that Access v2000 was extremely stable under XP Home (except that the Help system never worked properly). Access v2002 under XP Professional is very flakey; I got frequent "Access has encountered a problem and needs to close" messages for quite a while. On one occasion I had to move all my objects into a fresh database, and then rebuild all the relationships, to rectify the situation. I wonder whether working on the same database from two different domains - one for work and one for home - has any corrupting action. Anyway I have not had the messages for a while now.

    Regarding the GoToControl, Me and SetFocus dilemma I can only say that I have noticed a fine distinction in later versions of Access between Me and the current record. In fact I have also had the "not in current record" message and have gone as far as to debug by printing out all the control names in Me when this occurred. Sure enough there was the name I was trying to target. Conclusion? Me was at that instant not the current record. Why? Anyone's guess. The latter versions of Access also seem to have the concept of a focus for each and every form object. So I'm not surprised that Me.Control.SetFocus works but it does not necessarily mean this is where the cursor is.

    None of this helps very much does it? Except perhaps to re-assure you that you're not alone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts