Results 1 to 2 of 2

Thread: how to change record source of a form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2012
    Posts
    90

    how to change record source of a form

    I have a form with a command button and a list box. The list box has the name of "$_importerrors" tables from within the current database. A user will select one of these values and click the command button. What I would like to do is change the record source of the called form so that the records in the selected '$_importerrors' table are displayed when the form opens.

    I read that using recordsource = "SQL" would enable this to work but all I have it the report running against the table which I created it so recordsource isn't be changed.

    Just to add some detail in case it helps;
    Main form with the command button and listbox is called 'frmRefresh'
    Called form with a datasheet view is called 'frmViewErrors"
    It is 'frmViewErrors' that I need to have the recordsource change on

    Any help appreciated.

    Thanks.
    Last edited by scoobster; May 19th, 2014 at 04:32 PM.

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jun 2012
    Posts
    90

    Re: how to change record source of a form

    don't worry. I solved it myself.

    Code:
    mysql = "SELECT [Sheet99$_ImportErrors].* FROM [Sheet99$_ImportErrors]; "
      
    DoCmd.OpenForm "frmViewImportErrors", acFormDS, , , acFormReadOnly
    Forms.ITEM("frmViewImportErrors").RecordSource = mysql

Posting Permissions

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



Click Here to Expand Forum to Full Width