• return to main form from subform (Access 2000 SP2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » return to main form from subform (Access 2000 SP2)

    Author
    Topic
    #407728

    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?

    Viewing 1 reply thread
    Author
    Replies
    • #855212
      • #855225

        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.

      • #855248

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

        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

        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.

        • #968904

          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! thankyou Thanks! thumbup

      • #855249

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

        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

        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.

    • #855213
    Viewing 1 reply thread
    Reply To: Reply #855212 in return to main form from subform (Access 2000 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel