Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open Form by Click on Datasheet Record (A2K)

    I would like for my database users to be able to click on a datasheet record and have a "detail" form open for editing the record. I have created both forms, but can't seem to work out this functionality.

    Does anyone know of an example of this? Other suggestions?

    Thanks.

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Form by Click on Datasheet Record (A2K)

    I have done this by making two forms. A tabular form to show the records and a columnar form for editing a chosen record. On the tabular form, place a button to the left of the fields in the detail section. My code is in Access 97, but it will open the editing form for the appropriate record when the button on that line is clicked.

    <pre>Private Sub cmdyourbutton_Click()

    On Error GoTo Err_cmdyourbutton_Click

    Dim stDocName As String
    Dim stLinkCriteria As String


    stDocName = "youreditform"

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


    Exit_cmdyourbutton_Click:
    Exit Sub


    Err_cmdyourbutton_Click:
    MsgBox Err.Description
    Resume Exit_cmdyourbutton_Click

    End Sub
    </pre>


    If you need more direction, post back.

  3. #3
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Open Form by Click on Datasheet Record (A2K)

    If using datasheet form, you can use the Form Click or DblClick event procedure to open the detail form. Simple example:
    <pre>Private Sub Form_Click()
    DoCmd.OpenForm "Detail_frm", , , "[ID] = '" & Me.ID & "'"
    End Sub</pre>

    With datasheet form when you click (or double-click) selected record, the form Click (or DblClick) event will be trigerred. I normally use the DblClick rather than single Click event because the DblClick event can be cancelled, the single Click cannot.
    HTH

  4. #4
    New Lounger
    Join Date
    May 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Form by Click on Datasheet Record (A2K)

    Thomas & Mark,

    Thanks for the posts and suggestions. After I posted my question, I made some progress on this issue that led me in the direction you both suggested. Your suggestions got me finished. Thanks again.

Posting Permissions

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