Results 1 to 7 of 7
  1. #1
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52

    Switch Recordsource with VBA without writing an SQL statement


    I have a form that I want to be able to run from several different queries at different times. I want to have buttons on another form to open this form and select the recordsource. I do not know how to write SQL, so if it is possible to change the recordsource of the form without writing an SQL statement that would be super.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You can set the source to the name of a saved query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    Quote Originally Posted by pbaldy View Post
    You can set the source to the name of a saved query.
    That's good news. Can you give me the VBA code to implement this?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    There are examples in VBA help on "recordsource".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    Thank you for what help you gave me, however I cannot find any threads on this topic nor can I find the section "VBA help".............. got a link to the thread?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    I meant using Help within the VBA editor program. Here's an example from it:

    Forms!frmCustomers.RecordSource = "Customers"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    That's it! Thanks a lot sir

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 03-27-2010, 11:18 AM
  2. Replies: 2
    Last Post: 10-16-2009, 02:47 PM
  3. update recordsource of subform
    By AndyKim in forum Forms
    Replies: 1
    Last Post: 06-16-2009, 09:15 AM
  4. I need help writing a query statement
    By dking in forum Queries
    Replies: 1
    Last Post: 02-25-2009, 09:43 AM
  5. Switch and Tables
    By UtilityRyan in forum Database Design
    Replies: 0
    Last Post: 06-12-2007, 03:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums