Results 1 to 4 of 4
  1. #1
    onechriswhite is offline Novice
    Windows Vista Access 2002 (version 10.0)
    Join Date
    Jul 2010
    Posts
    22

    Running a report with a where condition

    Hi,



    I need one report run under several conditions. It will show student test results but I will need it to print for a particular class (ClassIDKey) and a particular test (TestIDKey) when called from one form, or all classes when called from another form.

    I have added a where clause to the "on click" event of the command button that calls it - I want it to print for a particular class and test that are currently open on another form (FRMStudentTestMarks):

    "TestIDKey=" & [Forms]![FRMSTudentTestMarks].[TestIDKey] & " AND ClassIDKey=" & [Forms]![FRMSTudentTestMarks].[ClassIDKey]

    I can't get it to work! Should I be using the "Filter" option instead?

    Thank you

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    If The query in the report has this in its criteria, it will work. IF you always use both filter fields.
    if sometimes, only 1 field is used, it will fail. My reports use your method and it works.

    Test by picking your items in the fields, validate in Immediate window (ctrl-G) by
    ?forms!frmStudentTestMark!testID

    dont use periods...use exclamations.
    test all criteria here to make sure of your values.

  3. #3
    onechriswhite is offline Novice
    Windows Vista Access 2002 (version 10.0)
    Join Date
    Jul 2010
    Posts
    22
    Hi, thanks for the reply.
    I don't want the condition in the query as I want to use the same query for other reports.
    I took away the characters trying to "build" a text SQL query and just wrote it plain with exclamations and it works:
    [ClassIDKey]=[Forms]![FRMStudentTestMarks]![ClassIDKey] And [TestIDKey]=[Forms]![FRMStudentTestMarks]![TestIDKey]

    What's the difference between . and ! in these cases?

    Thanks again, happy it works now!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    The . invokes intellisense popup tip in VBA.

    I use . when I want to reference control names, ! for field. If control has same name as field it is bound to, either character should work.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 5
    Last Post: 04-10-2015, 03:10 AM
  2. Generating a report based upon a condition
    By CaveCanem in forum Programming
    Replies: 2
    Last Post: 03-27-2014, 01:56 PM
  3. Where condition in report text box
    By kazaccess in forum Reports
    Replies: 3
    Last Post: 07-29-2013, 10:00 AM
  4. Report and IF Condition
    By ismailkhannasar in forum Queries
    Replies: 1
    Last Post: 01-31-2013, 04:29 AM
  5. Open a report with a date condition
    By Grooz13 in forum Reports
    Replies: 3
    Last Post: 08-02-2010, 02:35 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