Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    SetFocus disaster Access97

    I have a problem with a control which ought to set focus to a control on a subform.

    The original code was deficient in that it failed to function (without error) if the customer moved focus in the subform:
    Private Sub QuickFind_AfterUpdate()
    ItemNo = Me![QuickFind]
    DoCmd.GoToControl "zInvQuickLookup"
    DoCmd.FindRecord ItemNo, A_ENTIRE, False, A_DOWN, False, A_CURRENT
    End Sub

    I changed it to the "preferred" (according to the help file) method:
    Private Sub QuickFind_AfterUpdate()
    ItemNo = Me![QuickFind]
    Me![zInvQuickLookup].Form![Item Number].SetFocus
    DoCmd.FindRecord ItemNo, A_ENTIRE, False, A_DOWN, False, A_CURRENT
    End Sub

    The result is an "illegal operation" error.

    As if that weren't bad enough once that line has been entered the database appears to be corrupted. Even when the offending line has been removed it is no longer possible to decompile, compile, repair, compact, or copy to a new database without getting the "illegal operation" error.

    I have restored the last clean copy (and ensured that it worked) and duplicated the error on two computers.

    Help!

  2. #2
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SetFocus disaster Access97

    Your problem might not be with the new code that your writing, it may be an existing problem with your database that only comes to light when you try to use this new code.

    I would suggest, if you haven

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: SetFocus disaster Access97

    I thought this repair idea should be noted

    <A target="_blank" HREF=http://www.vb123.com/toolshed/news/issue19.htm>Full news letter here</A>

    Welcome To Tips-FX - Edition 19

    Tips-FX is an email newsletter that provides free tips, help and information for skilled Microsoft Access users and related software disciplines.

    Produced by Garry Robinson from Sydney, Australia.

    In this edition

    GOING BACKWARDS IN A FORM
    SMALL SCREEN DUMPS
    HOW DOES GRAF-FX WORK ? - YOU CAN FIND OUT
    VISUAL BASIC FOR CE WINDOWS
    MSDN ONLINE- SOME GREAT FREE ARTICLES
    FREE STUFF
    DATA TRANSFORMATION SERVICES
    CORRUPTED ACCESS 97 DATABASE - AN UNLIKELY REPAIR IDEA
    GOOD READING AND USEFUL SITES







    CORRUPTED ACCESS 97 DATABASE - AN UNLIKELY REPAIR IDEA

    One of my clients had a corrupted backend database that would simply just not open in Access 97 (on a number of PC's). Nor would the tables import or link from another Access 97 database. PANIC...

    The solution was to be found in Access 2000 which managed to repair the database and convert it to Access 2000 format. I then used the Convert back to Access 97 option in Access 2000 to return the data only database to Access 97 in a useable state. WHEW !!!
    -------------------------------------------------------

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: SetFocus disaster Access97

    In that case, you either corrupted the database, or you removed the wrong line.

    Is zInvQuickLookup your subform CONTROL (not the name of the form itself, unless they're the same)? If not then you can't do this
    <hr>Me![zInvQuickLookup].Form![Item Number].SetFocus<hr>
    I've also found that the reliable way to actually get the focus into a control on the subform is to use a two-step process. First, set the focus to the subform.form. Then set the focus to the subform's control. After that, your find should proceed normally.
    Charlotte

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    Re: SetFocus disaster Access97

    Once the error is introduced any action on the database (decompile, repair, copy etc) all result in an illegal action failure. Thanks for the link in your second post. It gave me a couple of other approaches, alas to no avail.

  6. #6
    Star Lounger
    Join Date
    Jan 2001
    Location
    Chatham, Ontario, Canada
    Posts
    86
    Thanks
    5
    Thanked 1 Time in 1 Post

    Re: SetFocus disaster Access97

    I'm pretty sure that I removed the right line as I have lots of practice at it now.

    zInvQuickLookup is both control and form.

    I must be a bit thick today (or possibly numb by now) as I don't follow your two step process.

    Me![zInvQuickLookup].Form.SetFocus
    Me![zInvQuickLookup].Form![Item Number].SetFocus??

    I have since discovered that if I copy in an unadulterated version, make the change and then immediately exit, decompile, compile, and compact then I get a 2162 runtime error on the search line. This doesn't help a lot since the suggestions include making the search case insensitive and limiting it to the current field, and ensuring that it is on a bound control. This should already be the case.

    This error is only returned the first time and thereafter the file appears to be corrupted.

Posting Permissions

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