Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Apr 2008
    Posts
    188
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code to open a form (2002/sp3)

    I am trying to write code to open a form using a different query than the one listed in the form. This is my effort which does not work.

    DoCmd.OpenForm "frmViewRawData", acFormDS, "qrydata"

    What am I doing wrong?

    Thanks.

    Paul

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

    Re: Code to open a form (2002/sp3)

    The third argument of OpenForm (the FilterName argument) does not replace the record source of the form; it is used to filter the records within the existing record source.
    You can change the record source as follows:

    DoCmd.OpenForm "frmViewRawData", acFormDS
    Forms("frmViewRawData").RecordSource = "qrydata"

    You must make sure that the query has the same fields as the original record source.

Posting Permissions

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