Results 1 to 7 of 7
  1. #1
    kduznetsov is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Posts
    5

    Need serious help before a final exam...


    This exam will not include SQL, so I need things the default way they're done..

    Firstly I basically need a query run to write if a book is in a "Circulation" table, then it is not availible. Ive tried various "IIf" but none of them do the job, because it's in two different tables. It does have a "date" field so I tried to make it say if date is null, then the book is Availible, but to no avail.

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Why don't you post your tables and the fields for each. Then post the SQL statement for your query that you have attempted let us see what it looks like.

    It is tough to visualize without seeing the layouts.

    Alan

  3. #3
    kduznetsov is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Posts
    5

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    You need to do a join query between Inventory and Circulation tables. Jointype 'show all from Inventory...' Then in the criteria row under DateOut or Circulation.ObjectID fields you can put Is Null - to show all books not checked out or - Not Is Null - to show books that are checked out. However, I see possible issue with this structure. Will Circulation table retain record for every time a book is checked out, in other words, history of activity for each book? This means one-to-many relationship and the simple join query will not serve. You will have to first query the Circulation table for the latest checkout for each book. This is a Totals (or aggregate) query using Max function on the DateOut field then join that query to the Inventory table.
    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.

  5. #5
    kduznetsov is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Posts
    5
    SELECT Inventory.ItemID, Inventory.Category, Circulation.DateOut, IIf([Circulation.DateOut]>"5/21/11","No","Yes") AS BookOut
    FROM Inventory INNER JOIN Circulation ON Inventory.ItemID = Circulation.ItemID;

    This is the SQL, what exactly is wrong with my IIf statement, book out turns into #Error..

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Ok, I think I have it. In a query, join your Inventory.ItemID in a left join to Circulation.ObjectID. Put them both in your QBE grid and set the criteria for the Circulation.ObjectId to "IsNull" This will then list everything in your inventory that is available for circulation.

    Alan
    Last edited by alansidman; 05-22-2011 at 08:12 PM. Reason: June--you are just to fast for me.

  7. #7
    kduznetsov is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Posts
    5
    Thanks, the following query worked:
    SELECT Inventory.ItemID, Inventory.Category, Circulation.DateOut, IIf(isNull(Circulation.DateOut),"No","Yes") AS BookOut
    FROM Inventory LEFT JOIN Circulation ON Inventory.ItemID = Circulation.ItemID;

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

Similar Threads

  1. At the final hurdle
    By GWB in forum Queries
    Replies: 2
    Last Post: 01-28-2011, 11:13 AM
  2. USG Clinic exam system: Changing User
    By isnpms in forum Access
    Replies: 2
    Last Post: 08-22-2010, 07:31 PM
  3. How to create an Exam Question Bank
    By yus786 in forum Database Design
    Replies: 1
    Last Post: 02-04-2010, 08:48 AM
  4. Access 2007 77-605 exam
    By Sheri Kelly in forum Access
    Replies: 0
    Last Post: 10-01-2009, 02:53 PM
  5. Help me asap... I need this for my exam
    By freelance_jhoe26 in forum Access
    Replies: 1
    Last Post: 04-20-2009, 02:30 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