Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29

    Write Code to Navigate from Subform to Subform

    I'm not having any luck writing code to navigate from a subform to another subform on the same main form.

    I have had luck writing code from the subform to the main form, using this:
    Private Sub attVeterinaryCertificate_LostFocus()
    Me.Parent![attApplication].SetFocus
    End Sub

    help?

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    it depends on how "deep" the subform is located. Is it on the same level?? as in, one level deep??

    I would assume then, that this would work:
    Code:
    me.parent.subformcontrol.form.setfocus
    right???

  3. #3
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    subform 1: sbfrmRabiesVaxLicensingAnimals
    last field: numCitationsIssuedRabiesViolations

    subform 2: sfrmRabiesVaxLicensingDOGS
    first field: numDogsVax

    Your recommended code:
    me.parent.subformcontrol.form.setfocus

    SO...
    me.parent.numDogsVax.form.setfocus
    OR
    me.parent.numDogsVax.sfrmRabiesVaxLicensingDOGS.se tfocus

    Does it go on the onExit of numCitationsIssuedRabiesViolations?

    I've tried a few combinations without luck. Thanks!

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    well it doesn't matter where it goes really, because setting focus to a subform itself really doesn't do anything that a user can see and use unless you set focus to a control ON that subform right after that.

    why do this? to tell the user to enter the next piece of data into the next subform??

  5. #5
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    The main form just happens to contain two subforms back-to-back.
    I could have the user press cntrl/tab to exit out of the first subform and enter into the next subform, but not many people would know how to do that, so I'm looking for code that will accomplish this task automatically so the user can just use the tab button and navigate appropriately through the form.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what does "tried that without luck" mean??

  7. #7
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    Well, if I were writing code to tab from a subform to a field on the main form, then I would write:
    Private Sub LastFieldNameonSubform_LostFocus()
    Me.Parent![FieldNameonMainForm].SetFocus
    End Sub

    You recommended:
    me.parent.subformcontrol.form.setfocus

    I was unsure if "form" would be the form name or remain the word "form." I figured "subformcontrol" was the first field on the next subform that I wanted to tab to.

    So, I tried this:
    me.parent.numDogsVax.form.setfocus on the onExit of the last field in subform 1, but it didn't work.

    So, then I tried this:
    me.parent.numDogsVax.sfrmRabiesVaxLicensingDOGS.se tfocus on the onExit of the last field in subform 1, but it also didn't work.

    Then I started to get confused and thought maybe the code was supposed to go on the onLostFocus field of Subform 1, not the particular field.


  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you know the difference between a subform control and the actual form object, right?

    for instance, if I was doing what you were doing, I would write this (which i've tested for years, always with success):
    Code:
    on whatever_event()
    
    forms(me.parent.name).controls("subformControlName").setfocus
    forms(me.parent.name).controls("subformControlName").form.controls("nextsubformControlName").setfocus

  9. #9
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    The subform control would be the control that links the subform to the main form, right? So that would include the source object, master field, and child field.

    The actual form object would be the subform itself?

  10. #10
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    did you try that code of mine?

  11. #11
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    I really don't know why this is so hard for me to understand.

    For: forms(me.parent.name)- is "name" the name of the main form?
    For: ("subformControlName")- is that the child field that links to the main form's parent field?

    Thanks for being patient with me. . . .

  12. #12
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    it's better to memorize it, or take the advice of someone who already knows it. this subform thing is not new. noone seems to get it, EVER.

    forms(me.parent.name)- is "name" the name of the main form?
    yes, but I've already done the work for you.

    ("subformControlName")- is that the child field that links to the main form's parent field?
    no, it's a control name, nothing else. this is the confusion, and it's not really worth explaining.

    once again, did you try what I posted or not?? honestly, taking advice with something like this is a lot easier than learning to understand it yourself.

  13. #13
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    I'm still not understanding where things go, even though I'm looking at the code you gave me.

    Main form: frmLRCAMain
    subform1: frmRabiesVaxLicensingAnimals
    subform control: tblRabiesVaxLicensingAnimals
    subform2: frmRabiesVaxLicensingDogs
    subform control: tblRabiesVaxLicensingDogs

    Using this template:
    forms(me.parent.name).controls("subformControlName ").setfocus
    forms(me.parent.name).controls("subformControlName ").form.controls("nextsubformControlName").setfocu s

    Does this look right?
    forms(me.parent.name).controls.tblRabiesControlVax Animals.setfocus
    forms(me.parent.name).controls.tblRabiesControlVax Animals.form.controls.tblRabiesControlVaxDogs.setf ocus

    That doesn't work as you probably know.

  14. #14
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    upload your file and tell me what you're looking for. as in:

    • forms to look at
    • subforms on that form to look at
    • what you want to have happen


    that's really the best I can do. and I'm looking out for you as well, because doing it this way will save you a heck of a lot of time going back and forth like this on a forum.

    it's simply too complex. the reason doesn't matter, but some concepts in a software program are just that way. Blame microsoft. I hope you can understand that. if you have sensative data, upload some fake data with the same layout.

  15. #15
    Swilliams987's Avatar
    Swilliams987 is offline Need Not Be Novice
    Windows XP Access 2010 32bit
    Join Date
    Jan 2011
    Location
    Sacramento, CA
    Posts
    29
    I am having trouble uploading the database because it's apparently too large. Though, it is very, very small only contains 1 or 2 records of fake data. Do you have any suggestions or know why the file is considered to large for upload?

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

Similar Threads

  1. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 AM
  2. Replies: 15
    Last Post: 11-09-2010, 04:27 PM
  3. Replies: 6
    Last Post: 11-05-2010, 10:11 AM
  4. Replies: 4
    Last Post: 01-11-2010, 11:41 PM
  5. Replies: 2
    Last Post: 10-19-2006, 04:37 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