Opening 2nd form after selecting a record

Discussion in 'Microsoft Access Forms' started by Guest, Nov 9, 2004.

  1. Guest

    Guest Guest

    How do I open a 2nd form after user selects a record on the 1st
    form(datasheet view) The 2nd form contains more details Thanks for your help
     
    Guest, Nov 9, 2004
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Hi, Eddie.

    You can't put a button on a form in datasheet view. One option is to
    include a button on a Continuous Form, which can be made to look much like
    datasheet view.

    Or you could use another event, such as double-clicking on a field. The
    following code opens a second form by clicking on the ID field, and filters
    the second form by matching the ID field to the value of the current record
    on the 1st form.

    Private Sub ID_DblClick(Cancel As Integer)
    On Error GoTo Err_ID_DblClick

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "PUTYOUR FORMNAME HERE"

    stLinkCriteria = "[ID]=" & Me![ID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_ID_DblClick:
    Exit Sub

    Err_ID_DblClick:
    MsgBox Err.Description
    Resume Exit_ID_DblClick
    End Sub

    HTH
    Sprinks


    "EddieZ" wrote:

    > How do I open a 2nd form after user selects a record on the 1st
    > form(datasheet view) The 2nd form contains more details Thanks for your help
     
    Guest, Nov 9, 2004
    #2
    1. Advertisements

  3. Guest

    StCyrM Guest

    Good evening

    The general statement would be as follows. Simply replace frmDetails with your
    form name as well as the RecordID with the proper ID


    DoCmd.OpenForm "frmDetails", _
    WhereCondition:="RecordID=" & Me.RecordID


    Best Regards

    Maurice St-Cyr
    Micro Systems Consultants, Inc.


    >How do I open a 2nd form after user selects a record on the 1st
    >form(datasheet view) The 2nd form contains more details Thanks for your
    >help
     
    StCyrM, Nov 12, 2004
    #3
  4. Guest

    Guest Guest

    I would like to use the information from this original email to open a
    Report(rather then a Form) from a Form after selecting record.

    The coding works if I create a Form named "Label" but I cannot figure out
    how to specify and open a Report named "Label".

    I have attached the VB code I'm using for your review. First I save the
    selected record and then I would like to open the report named "Label".

    Private Sub Save_Click()
    On Error GoTo Err_Save_Click


    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Label"

    stLinkCriteria = "[Key]=" & Me![Key]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    Exit_Save_Click:
    Exit Sub

    Err_Save_Click:
    MsgBox Err.Description
    Resume Exit_Save_Click
    End Sub

    Sorry but I am brand new at using VB coding in Access.

    Thanks so much for any help,

    NikkiB

    "EddieZ" wrote:

    > How do I open a 2nd form after user selects a record on the 1st
    > form(datasheet view) The 2nd form contains more details Thanks for your help
     
    Guest, Jun 13, 2005
    #4
  5. Guest

    Guest Guest

    Figured it out.

    Had to change:
    stDocName = "Label"

    stLinkCriteria = "[Key]=" & Me![Key]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    To:
    stDocName = "Label"

    stLinkCriteria = "[Key]=" & Me![Key]
    DoCmd.OpenReport stDocName, , , stLinkCriteria

    But this just automatically printed the report so I further changed the
    coding to open the report in print preview allowing the user to review the
    information. Here was the final coding I used.

    stDocName = "Label"

    stLinkCriteria = "[Key]=" & Me![Key]
    DoCmd.OpenReport stDocName, acPreview , , stLinkCriteria

    "NikkiB" wrote:

    > I would like to use the information from this original email to open a
    > Report(rather then a Form) from a Form after selecting record.
    >
    > The coding works if I create a Form named "Label" but I cannot figure out
    > how to specify and open a Report named "Label".
    >
    > I have attached the VB code I'm using for your review. First I save the
    > selected record and then I would like to open the report named "Label".
    >
    > Private Sub Save_Click()
    > On Error GoTo Err_Save_Click
    >
    >
    > DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    >
    > Dim stDocName As String
    > Dim stLinkCriteria As String
    >
    > stDocName = "Label"
    >
    > stLinkCriteria = "[Key]=" & Me![Key]
    > DoCmd.OpenForm stDocName, , , stLinkCriteria
    >
    > Exit_Save_Click:
    > Exit Sub
    >
    > Err_Save_Click:
    > MsgBox Err.Description
    > Resume Exit_Save_Click
    > End Sub
    >
    > Sorry but I am brand new at using VB coding in Access.
    >
    > Thanks so much for any help,
    >
    > NikkiB
    >
    > "EddieZ" wrote:
    >
    > > How do I open a 2nd form after user selects a record on the 1st
    > > form(datasheet view) The 2nd form contains more details Thanks for your help
     
    Guest, Jun 15, 2005
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Simsion
    Replies:
    4
    Views:
    571
    Kelvin
    Nov 10, 2003
  2. Guest
    Replies:
    0
    Views:
    280
    Guest
    Mar 12, 2006
  3. Michael
    Replies:
    0
    Views:
    189
    Michael
    May 4, 2006
  4. FA
    Replies:
    0
    Views:
    220
  5. tina
    Replies:
    1
    Views:
    290
Loading...

Share This Page