Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2010
    Posts
    186

    Unanswered: Need code to move from main form to subforms(Access 2007)

    I have a mainform frmAddAccount (master) with 2 subforms - subformNEWSTATUS (child) and subformNEWRegistrations (child) - they are linked by control "Account"

    When it opens on a new record, all 3 forms are there/new

    There are required controls in each of the 3 forms per entry. Operator will be using tab key from control to control

    I need to go:
    *from the last control in frmAddAccount Telephone
    *to subformNEWSTATUS, control STATLU, tab to control, then THIS SUBFORM CANNOT TAB INTO NEW SUBFORM RECORD
    it has to setfocus
    *to subformNEWRegistrations, control SLU, tab to control, tab to
    control, tab to last control then CANNOT TAB INTO NEW RECORD -
    *I want to go back to the main form on control exit button

    I have been trying to type the setfocus code using test data, but I think I have too much or too little in the exit event procedure (code in main form) because it doesn't work, I get error you can't go to this control:
    Private Sub Telephone_Exit(Cancel As Integer)

    Forms!frmAddAccount!subformNEWSTATUS.SetFocus
    DoCmd.GoToControl "STATLU"

    End Sub


    I also put a set focus on exit in subformNEWSTATUS:
    Private Sub StatNotes_Exit(Cancel As Integer)

    Forms!frmAddAccount!subformNEWRegistrations.SetFoc us


    End Sub

    and all I'm seeing is if the cursor sits for a minute on a control in the main form, it jumps into subformNEWRegistrations ? ? ? not sure if it's related to this, because it never brings me to subformNEWSTATUS

  2. #2
    Join Date
    Oct 2009
    Posts
    340
    it doesn't look like you have the syntax for nameing a subform control. in the AfterUpdate or OnExit event try this , without any DoCmd - just stand alone:

    Forms!frmAddAccount!subformNEWSTATUS.Form!YourCont rolName.SetFocus

  3. #3
    Join Date
    Jun 2010
    Posts
    186
    thank you - that one worked!

    Now - do you know how I get from subformNEWSTATUS[StatNotes] into subformNEWRegistrations[SLU] using OnExit event

  4. #4
    Join Date
    Oct 2009
    Posts
    340
    syntax is syntax - - ....use the exact same syntax just vary the names of the forms, subforms, controls...it is always:

    Forms!MainFormName.SubFormName.Form!ControlName

    and for a SetFocus task you add the .setfocus

    obviously if you mis-spell any of those it won't work - - and unfortunately doesn't supply any meaningful error message either - so one just has to be careful....

Posting Permissions

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