Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open SubForm on Blank Record (A2K)

    I have a need for a form to open on a new record and the following routine works on a single form.

    Private Sub Form_Load()
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    DoCmd.GoToRecord , , acNewRec
    End Sub

    However, I cannot get this to work on a subform of a form.

    MainForm Name: frm Inventory
    SubForm Name: frm Received

    SubForm Name on MainForm: subReceived.

    Would appreciate any suggestions. Thanks in advance for any help on this,

    Cheers,
    Cheers,
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open SubForm on Blank Record (A2K)

    You can set focus to the subform, then move to a new record, and if you wish set focus to a control on the main form again. You need to do this in the On Current event of the main form, so that each time the user moves to another record in the main form, the subform will be positioned on a new record. So the following goes into the code module of the main form. If you already have a Form_Current procedure, add the new lines to the existing ones.

    Private Sub Form_Current()
    ' Suppress error message if subform already on new record
    On Error Resume Next
    ' Set focus to subform
    Me.subReceived.SetFocus
    ' Go to new record
    RunCommand acCmdRecordsGoToNew
    ' Set focus back to control in main form (substitute appropriate name)
    Me.SomeControl.SetFocus
    End Sub

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open SubForm on Blank Record (A2K)

    Many thanks and a Happy New Year to you Hans. I'll get to this as soon as I get back from my dentist where we get to play "Root Canal!!"

    Cheers,
    Cheers,
    Andy

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open SubForm on Blank Record (A2K)

    Hans,

    Now that I'm out of my Root Canal Coma I thought that I'd let you know, that

    as always

    your suggestion worked perfectly.

    Thanks again,
    Cheers,
    Andy

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open SubForm on Blank Record (A2K)

    I hope it soothes the pain a bit.

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open SubForm on Blank Record (A2K)

    Both mental & physical!
    Cheers,
    Andy

Posting Permissions

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