Results 1 to 8 of 8
  1. #1
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187

    Query only works if I have atleast 1 record in table

    This query works great...but only if I have atleast 1 record in Attendance table. I'd like it to work even when Attendance is empty (which it will be when I first deploy this to the team). I can populate a dummy record if required but I'd rather not.



    Intention is to grab all people with "Attendee","Scheduler","Admin" access AND get "Attendee (temp)" people IF they have a record in the attendance table for the current event.

    Attendance table:
    ID
    EventID
    EmployeeID

    Code:
    SELECT Q1.Security.ID AS EmpID, Q1.Security.FirstName & " " & Q1.Security.LastName AS EmployeeName
    FROM (SELECT Security.ID, Security.FirstName, Security.LastName FROM Events, Security, Attendance WHERE ((Attendance.EmployeeID=Security.ID) AND (Forms!Navigation!NavigationSubform.Form!ID = Attendance.EventID) AND (Security.Access ="Attendee (temp)")) OR (Security.Access IN ("Attendee","Scheduler","Admin")))  AS Q1
    GROUP BY Q1.Security.ID, Q1.Security.FirstName & " " & Q1.Security.LastName
    ORDER BY Q1.Security.FirstName & " " & Q1.Security.LastName;
    Last edited by BRZ-Ryan; 12-30-2013 at 08:03 PM.

  2. #2
    mrojas is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    Test if there are any records with the DCount function. If value returned is zero, there are no records in table.

  3. #3
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187

    Re: Query only works if I have atleast 1 record in table

    You didn't understand my question.. My query only works if 1+ records exist in Attendance table, I need it to work even if 0 records.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Perhaps not running the query when there are 0 records is an option.

  5. #5
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187

    Re: Query only works if I have atleast 1 record in table

    This query populates a combobox in a continuous form to create records in attendance. I want an explanation as to what I did wrong, not work arounds.

  6. #6
    mrojas is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2013
    Location
    Concord California
    Posts
    72
    I should have been more explicit. Do not run your query if there are no records.

  7. #7
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187

    Re: Query only works if I have atleast 1 record in table

    Smh.. then how do I get a record in my attendance table?

    This combobox needs to be populated so I can select an item to create a record in Attendance table. The above query populates the combobox.

    Something is wrong with my query, if you don't know how to help then don't help.

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by BRZ-Ryan View Post
    This combobox needs to be populated so I can select an item to create a record in Attendance table. The above query populates the combobox.
    At the risk of not being any help, this seems to be a pretty good description of what the underlying problem is.

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

Similar Threads

  1. Replies: 32
    Last Post: 05-23-2013, 04:16 PM
  2. Printing report from first record works...
    By TinaCa in forum Programming
    Replies: 10
    Last Post: 01-17-2012, 10:59 AM
  3. Replies: 2
    Last Post: 12-05-2011, 03:44 AM
  4. Simple Database (atleast I *think* it should be)
    By CloudFuel in forum Database Design
    Replies: 6
    Last Post: 06-28-2010, 10:40 AM
  5. Replies: 1
    Last Post: 10-20-2009, 02:05 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