Consulting

Results 1 to 3 of 3

Thread: Open a SubForm to display required data

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Open a SubForm to display required data

    Hi All,
    Best wishes for the New Year.
    I've reached my limit on Access again!

    I have a form ?Companies? which contains 2 subforms
    Contact_SubForm

    subContact



    subContact is used as a ?lookup? and from a button on this form I want to open the record for the Company and the Contact. The record for the company on ?Companies? is opened by the code below. What I need help with is opening the subform to the correct record with the Contact details. The field Contact_No is used on Companies and Contact_Subform to link these, and on subContact to be used in the code.

    [VBA]
    Private Sub CommandShowDetail_Click()
    On Error GoTo Err_CommandShowDetail_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "Companies"

    stLinkCriteria = "[ID]=" & Me![ID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Parent!CommandCloseForm.Visible = True

    Exit_CommandShowDetail_Click:
    Exit Sub
    Err_CommandShowDetail_Click:
    MsgBox Err.Description
    Resume Exit_CommandShowDetail_Click
    End Sub
    [/VBA]

    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    Y'know Malc, I'm not entirely sure this belongs in the Outlook forum
    K :-)

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Ok I'm still in Happy Holiday mode! (Moved)
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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