Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142

    Set Focus Multiple Sub Forms


    I have a form [frmTransactions] containing eight sub forms, the sub forms are either hidden or visible when combo [Categories] is completed, I want to set the focus on a Text Box within the sub forms i.e.

    Category = "Transport" subForm = [frmBreakdownTransport] Text Box = [trbRate]

    I tried the following code:
    Code:
    If Me!TranCat = "Transport" Then
        Forms![frmTransactions]![frmBreakdownTransport]![trbRate].SetFocus 
    End If
    and repeated with seven ElseIf's

    But the error message " cant find frmBreakdownTransport" displays ???

    Can anyone tell me what I am doing wrong?

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Try:
    Code:
    Me![frmBreakdownTransport].Form![trbRate].SetFocus
    Edit: Here's good summary on how to refer to forms and subforms controls and objects.

  3. #3
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    I get the same error message
    "cant find the field frmTransport referred to in your expression????

  4. #4
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Same error message??

  5. #5
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Can you paste code on which it breaks?

  6. #6
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Code:
    Private Sub Text194_Enter()
    If Me!TranCat = "Misc" Then
        Forms![frmTransactions]![frmBreakdownMisc]![trbRate].SetFocus
    ElseIf Me!TranCat = "Finance" Then
        Forms![frmTransactions]![frmBreakdownFinance]![trbRate].SetFocus
    ElseIf Me!TranCat = "Transport" Then
        Forms![frmTransactions]![frmBreakdownTransport]![trbRate].SetFocus
    ElseIf Me!TranCat = "Home" Then
        Forms![frmTransactions]![frmBreakdownHome]![trbRate].SetFocus
    ElseIf Me!TranCat = "Goverment" Then
        Forms![frmTransactions]![frmBreakdownGovernment]![trbRate].SetFocus
    ElseIf Me!TranCat = "Grocery" Then
        Forms![frmTransactions]![frmBreakdownGrocery]![trbRate].SetFocus
    ElseIf Me!TranCat = "Utilities" Then
        Forms![frmTransactions]![frmBreakdownUtilities]![trbRate].SetFocus
    ElseIf Me!TranCat = "Dining" Then
        Forms![frmTransactions]![frmBreakdownDining]![trbRate].SetFocus
    End If
    'Me![frmBreakdownTransport].Form![trbRate].SetFocus
    End Sub[

  7. #7
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Ok.
    First, you didn't apply what I told you to your code, only to that one line with [frmBreakdownTransport] and it's commented anyway so either you don't want help with that or I don't know what else.
    Second, there's nothing about
    frmTransport in this part of code so it probably breaks somewhere else and that "somewhere else" is the part I'd like you to paste.

  8. #8
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    I am sorry for misunderstanding I commented my code and pasted your code but I received the same error message so I changed it back and commented your code for future reference.
    The Transport ref is the 6th line of code [frmBreakdownTransport] but it never gets past the first line of code [frmBreakdownMisc]?

  9. #9
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    This is what I tried:
    Code:
    Private Sub Text194_Enter()
    If Me!TranCat = "Misc" Then
        Me![frmBreakdownMisc].Form![trbRate].SetFocus
    'ElseIf Me!TranCat = "Finance" Then
        'Forms![frmTransactions]![frmBreakdownFinance]![trbRate].SetFocus
    'ElseIf Me!TranCat = "Transport" Then
     '   Forms![frmTransactions]![frmBreakdownTransport]![trbRate].SetFocus
    'ElseIf Me!TranCat = "Home" Then
    '    Forms![frmTransactions]![frmBreakdownHome]![trbRate].SetFocus
    'ElseIf Me!TranCat = "Goverment" Then
    '    Forms![frmTransactions]![frmBreakdownGovernment]![trbRate].SetFocus
    'ElseIf Me!TranCat = "Grocery" Then
    '    Forms![frmTransactions]![frmBreakdownGrocery]![trbRate].SetFocus
    'ElseIf Me!TranCat = "Utilities" Then
    '    Forms![frmTransactions]![frmBreakdownUtilities]![trbRate].SetFocus
    'ElseIf Me!TranCat = "Dining" Then
    '    Forms![frmTransactions]![frmBreakdownDining]![trbRate].SetFocus
    End If
    'Me![frmBreakdownTransport].Form![trbRate].SetFocus
    End Sub

  10. #10
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    I tried this when [frmBreakdownMisc] was visible

  11. #11
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Again, you need to change ALL your references to subforms and it's to controls to proper syntax (as in post #2). And no, frmBreakdownTransport is not the same as frmTransport that you receive error message about (and that says FIELD which clearly indicates issues with syntax).
    So please, fix your references and try again.

  12. #12
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Ok sorry to bother you

  13. #13
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    I changed the names, etc, and tried this code
    Code:
    Private Sub Text194_Enter()
    If Me!TranCat = "Finance" Then
        Forms![frmTransactions]![frmSubBreakdownFinance].SetFocus
        Forms![frmSubBreakdownFinance]![trbRate].SetFocus
    End If
    End Sub
    and this code (your earlier suggestion)
    Code:
    Private Sub Text194_Enter()
    If Me!TranCat = "Finance" Then
        Me![frmSubBreakdownFinance].Form![trbRate].SetFocus
    End If
    End Sub
    I no longer get an error message, however in both cases instead of tabbing to the sub form it goes to the next record and sets the focus in [trbRate] on the next record.
    Hope you can bear with my ignorance?

  14. #14
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    I'm not sure what you want to achieve anymore. Isn't that what you wanted? To set focus on trbRate textbox?
    Maybe you could upload your database and try to explain once again what is it you want to achieve exactly?

  15. #15
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Yes I wanted to do that (set focus on trbRate textbox) but on the same transaction form, not to move to the next transaction record.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple picture change subform focus
    By ZOMB13 in forum Access
    Replies: 7
    Last Post: 04-26-2015, 12:36 AM
  2. Replies: 1
    Last Post: 09-03-2014, 01:36 PM
  3. Replies: 5
    Last Post: 02-20-2014, 11:05 AM
  4. Replies: 5
    Last Post: 09-05-2012, 06:42 PM
  5. multi forms open & focus issue
    By tfulmer in forum Programming
    Replies: 1
    Last Post: 08-23-2011, 04:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums