Results 1 to 2 of 2
  1. #1
    Daryl2106 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    167

    Setting query value form form

    Hi,



    I am trying to access the same query/report from different forms. For example I have a StudentAttendanceForm where users select a StudentID and then open the report. The query criteria for ID# is [Forms]![StudentAttendanceForm]![StudentID].

    Can I access this same report from an event on another form. I'm thinking that if I can some how assign the StudentID from the form I want to access the report from, to the criteria on the StudentAttendanceReport Query, this is possible. I am new to code but I am thinking something like:

    SET [StudentAttendanceQuery]![StudentID] TO [StudentEnrollmentForm]![StudentID]
    Open StudentAttendance Report

    The StudentEnrollmentForm is the other form I want to access the report from

    You may need a crystal ball for this one. Let me know what other info you need.

    In general I am finding I am copying and tweaking queries to meet specific user needs. For eamply some want to access a single student and other need "batch" reports. What is the general way about this/

    Thanks and take care,

    Daryl

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    One easy way to do this is to change the query to access one or two Tempvars variable(s), and set the same Tempvars in each case before calling the query.

    If you want to be able to use the same query to get a single student or all students, then you can either use
    Code:
    WHERE StudentID BETWEEN X AND Y
    and for a single student, set Tempvars X and Y both to the student ID, and for all students, set them equal to the low and high student IDs in the database.

    Alternately, you could use
    Code:
    WHERE StudentID LIKE X
    and for a single student, set Tempvars X to the student ID, and for all students, set it to *.
    Last edited by Dal Jeanis; 11-11-2013 at 11:54 AM.

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

Similar Threads

  1. Replies: 5
    Last Post: 10-24-2013, 04:38 PM
  2. Replies: 4
    Last Post: 10-24-2013, 12:32 PM
  3. Replies: 5
    Last Post: 01-03-2013, 07:47 PM
  4. setting up a form (calculations)
    By donnan33 in forum Forms
    Replies: 1
    Last Post: 12-22-2011, 11:17 AM
  5. Re setting form after each search
    By VinceHay in forum Forms
    Replies: 0
    Last Post: 12-08-2010, 03:35 AM

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