Results 1 to 3 of 3

Thread: Opening Form

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

    Opening Form

    Edited by HansV to provide link to post - see <!help=19>Help 19<!/help>

    I need to by clicking on Command Button A or Command Button B or Command Button C on frmSelection, open up frmAsset using various queries as the data source.

    Example:

    A. frmAsset qryByDescn
    B. frmAsset qryByCode
    C. frmAsset qryByLocation

    Theoretically I should be able to have something like

    DoCmd.OpenForm.frmAsset.RecordSource =
    Cheers,
    Andy

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

    Re: Opening Form

    You can pass the name of the query in the OpenArgs argument of OpenForm:

    DoCmd.OpenForm FormName:="frmAsset", OpenArgs:="qryByDescn"

    In the On Open event of frmAsset:

    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
    Me.RecordSource = Me.OpenArgs
    End If
    End Sub

    (Depending on how the queries differ from each other, there may be another way of doing this)

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

    Re: Opening Form

    Hans,

    I knew you'd know! I'll be testing this over the next couple of days.

    Thanks kindly,

    ps. added this after the above comments.

    Dropped everything else and got right to it, and . . . . . .

    Worked Perfectly <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    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
  •