Consulting

Results 1 to 2 of 2

Thread: Change record source on a Form via Combobox

  1. #1

    Change record source on a Form via Combobox

    How do I change record source on a Form via Combobox? VBA or?
    What I have now:
    1. The user chooses Form1 from Combobox, Form1 opens with record source to Table1
    The user chooses Form2 from Combobox, Form2 opens with record source to Table2
    Form1 and Form2 are identical, the only thing that changes is record source

    What I am trying to accomplish is:
    2. The user chooses A from Combobox then FormX opens and based on what user has chosen
    it changes the record source eg. to the Table A. This way I dont have to have a form A, B, C...



  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    You could just filter the data from just one table, which makes more sense than having more than one identically structured table.
    What you want to do can be done providing the tables have identical field names.
    You set the form Recordsource in the Combo "After Update Event Procedure" using
    me.recordsource = "tablename"
    or
    me.recordsource = "queryname"
    where tablename is the name of a table and queryname is the name of a query
    You will of course need one or more If/then or case statements to decide which record source fits the User's selecton.

Posting Permissions

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