Results 1 to 5 of 5
  1. #1
    FruStalin is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    18

    Thumbs up Help is neede to open a SubForm from a MainForm and make the SubForm active ?

    Hello there

    I have a MainForm in which I have build in a SubForm. The SubForm (Named [frmJournal] shall only be visible and functionel when called upon. For that I have a button (Click) on the MainForm when pressed makes the SubForm visible and should make the SubForm active and ready for a new new record. What happens is a seperate window opens, and that is not my intension.

    I belive that my problem has something to do with the referencing to the SubForm (Path). But I dont have any idea of how to put this into the DoCmd.OpenForm argument! I have tried with the "Path" string (in the code) without luck. So I need help/info on how to put a path into the DoCmd.OpenForm argument or how to solve this issue.

    The color green is code which is bypassed, color red is active code.

    Private Sub cmdNy_Click()


    Dim Path As String

    tglDetalje = True

    'Path = Forms![frmJournalMain]![frmJournal].Form

    'Vis og skjul underformular-felterne
    frmJournalMainSub1_Liste.Visible = False
    frmJournal.Visible = True

    'Me!frmJournal.Form.Sagsnummer.Enabled = False
    'Me!frmJournal.Form.GoToNewRecord

    DoCmd.OpenForm "frmJournal", acNormal

    'DoCmd.GoToRecord acDataForm, "frmJournal", acNewRec

    End Sub

    Hope someone are able to help me here.


    Regards

    Morten

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    A subform is a control on a form and does not get opened (only forms are opened). As a control on the main form, it is treated the same as any other control - e.g. you can make it visible/invisible

  3. #3
    FruStalin is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    18
    Hello aytee

    Do you have a suggetion to how I can it to work? What would you do?

    In stead of manually clicking a button to get from the main form to the subform and then again click a "New" button to get to a new record in the sub form, I need to be able to go from the main form, directly to the subform and be in a new record, by one click.
    This got to be possible. Anything else sound hopeless :-)

    Regards

    Morten

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    What is the record source for the subform, will there be other records pertaining to it? I'm not sure what the process of your form is - what prompts the subform to become visible, do the users add something new? I understand you want the subform to be shown empty so that they can add a new record so you need to point it there. Can you attach your database (or part of it) - would I understand it?

  5. #5
    FruStalin is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    18
    Hello aytee

    This code got the job done:

    DoCmd.GoToControl "frmJournal"
    DoCmd.GoToRecord , , acNewRec

    So it is possible. I was informed of this on another post :-)

    Anyway, thanks a lot for your effort and contribution.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-29-2011, 01:37 AM
  2. Replies: 4
    Last Post: 11-02-2011, 02:59 AM
  3. subform to open form w/ active master record
    By spitfire122 in forum Access
    Replies: 1
    Last Post: 06-28-2011, 04:28 PM
  4. Replies: 10
    Last Post: 12-31-2010, 12:35 PM
  5. Replies: 0
    Last Post: 03-14-2009, 12:33 AM

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