Results 1 to 4 of 4
  1. #1
    dinorbaccess is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2010
    Posts
    27

    Question Manipulating Form&Query Sources

    Hello everyone,



    Im facing a problem right now that seems to be simple but I cant find the solution alone. I tried many way but it doesnt work.
    Ive attached a sampl of my access file. Its very simplified, just to tell you where is my problem.

    So the problem is this.
    I have a table where for instance want to enroll students. For this table I have made queries for every month to select the students that are enrolled on specific month.
    Then I created a form frmStudent which has a source to these queries.
    I want to change the record source of my subform frmStudent which is placed in my main form on Combobox change event. The sources that I want to put in are the queries that I created.
    So what I want is, when I click a value on comboBox, first to change the record source of my subform frmStudent and then show it in my subform.

    My attach may help to explain my problem.

  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,521
    It is a mistake to make queries for each time period you want to query. Also, what are you going to do when you have two years worth of data?. Your combo doesn't allow for year. You want to create what's called a parameter query. It would rely on form controls or some other method to dynamically change the data it retrieved. In that event, you would base the subform on it and simply requery the subform when the combo updates. The easiest method would be to have two textboxes for a date range, and your query criteria would look like:

    Between Forms!MainForm.txtFromDate And Forms!MainForm.txtToDate

    presuming the two textboxes were named txtFromDate and txtToDate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dinorbaccess is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2010
    Posts
    27
    Quote Originally Posted by pbaldy View Post
    It is a mistake to make queries for each time period you want to query. Also, what are you going to do when you have two years worth of data?. Your combo doesn't allow for year. You want to create what's called a parameter query. It would rely on form controls or some other method to dynamically change the data it retrieved. In that event, you would base the subform on it and simply requery the subform when the combo updates. The easiest method would be to have two textboxes for a date range, and your query criteria would look like:

    Between Forms!MainForm.txtFromDate And Forms!MainForm.txtToDate

    presuming the two textboxes were named txtFromDate and txtToDate.
    Problem solved. Thnx for your idea man.
    God bless you

  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,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Insert query into table FROM two table sources
    By svcghost in forum Queries
    Replies: 2
    Last Post: 11-05-2010, 09:10 AM
  2. Manipulating datas on access table
    By 3rdeye in forum Access
    Replies: 6
    Last Post: 10-12-2010, 02:47 PM
  3. Query involving data from different sources
    By nodnud in forum Queries
    Replies: 1
    Last Post: 08-12-2010, 06:11 PM
  4. Link to multiple sources
    By AquaChaos in forum Import/Export Data
    Replies: 4
    Last Post: 06-16-2010, 02:43 PM
  5. one form two sources - invalid control source msg
    By techexpressinc in forum Forms
    Replies: 1
    Last Post: 05-28-2010, 02:11 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