Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    return to main form from subform (Access 2000 SP2)

    We have our data-entry form set up with a main form (representing the customer info) and a sub-form (representing the items they want). This is similar to the Order and Order subform in Northwind. The problem we're having is when the end user is in the subform entering items and then wants to add a new customer, the subform is still active, so they proceed to type away without noticing and then get stuck, as they haven't filled out the customer information first. Is there a way to get the focus back on the main form without having the user do, for example, a CTRL+TAB?
    Carpy Diem, it's .

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: return to main form from subform (Access 2000 SP2)


  3. #3
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: return to main form from subform (Access 2000 SP2)

    Hans - I sent you a note, but never mind about the link part. I guess Microsoft was just slow. I printed out the KB article and I'll let you know whether or not it works for us.
    Carpy Diem, it's .

  4. #4
    3 Star Lounger
    Join Date
    Jul 2001
    Location
    Minneapolis, Minnesota, USA
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: return to main form from subform (Access 2000 SP2)

    After I tried out the example in the KB article, I realized this wasn't exactly what I had in mind, as the vb code had to be tied to a specific field, and it would be impossible to tell exactly where the end user would be in the subform when they decided to add a new customer. So what I did was go to the first field on the subform (item) and put this code on the GotFocus event(where F_CustQuotesMain is the main form and F_CustQuotesSub is the subform):

    <font face="Comic Sans MS">Private Sub Item_GotFocus()
    On Error GoTo Error_Focus
    If IsNull(Forms![F_CustQuotesMain]![CustID]) = True Then
    MsgBox "Sorry, you cannot enter items without a customer."
    Forms![F_CustQuotesMain]![CustID].SetFocus
    Forms![F_CustQuotesMain]![F_CustQuotesSub].Requery
    End If
    Exit Sub
    Error_Focus:
    MsgBox "you must be on a record with data"
    Exit Sub
    End Sub</font face=comic>

    So now, when someone gets distracted and clicks the wrong thing, they're brought right up to the customer id field where they should have been in the first place.
    Carpy Diem, it&#39;s .

  5. #5
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: return to main form from subform (Access 2000 SP2)

    Peggy,
    I must commend you - you're one of the few loungers I've seen in a while who posts the solution to their problem! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> Thanks! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

Posting Permissions

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