Results 1 to 3 of 3
  1. #1
    AmanKaur123 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    47

    Change query to populate listbox

    I have one problem in the below query. It gives me only 'Yes' in agentsignoff field and supsignoff field For all the records.
    Code:
    strsql = "SELECT tblMeeting.MeetingID, tblMeeting.[Staff Number], tblMeeting.[Meeting Date], tblMeetingType.[Meeting Type], IIf([AgentSignOff] Is Null,'NA',IIf([AgentSignOff],'Yes','No')) AS Expr1, IIf([SupSignOff] Is Null,'NA',IIf([SupSignOff],'Yes','No')) AS Expr2 FROM (tblMeeting INNER JOIN tblMeetingType ON tblMeeting.MeetingTypeID = tblMeetingType.MeetingTypeID) LEFT JOIN tbl_RMS_Paperless ON tblMeeting.[Staff Number] = tbl_RMS_Paperless.AgentRef WHERE (((tblMeeting.[Staff Number]) =" & Me.cboMoveTo & ")) ORDER BY tblMeeting.[Meeting Date] DESC;"
    And if I remove the condition Staffnumber =cbomoveto then it works fine.



    But I need to see all the records of the individual for the meetings he attended.

    Any help will be much appreciated.

    Many Thanks

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    I formatted your statement for readability, substituting "999" for your parameter field.
    HTML Code:
    SELECT tblmeeting.meetingid, 
           tblmeeting.[staff number], 
           tblmeeting.[meeting date], 
           tblmeetingtype.[meeting type], 
           Iif([agentsignoff] IS NULL, 'NA', Iif([agentsignoff], 'Yes', 'No')) AS 
           Expr1, 
           Iif([supsignoff] IS NULL, 'NA', Iif([supsignoff], 'Yes', 'No'))     AS 
           Expr2 
    FROM   (tblmeeting 
            INNER JOIN tblmeetingtype 
                    ON tblmeeting.meetingtypeid = tblmeetingtype.meetingtypeid) 
           LEFT JOIN tbl_rms_paperless 
                  ON tblmeeting.[staff number] = tbl_rms_paperless.agentref 
    WHERE  (( ( tblmeeting.[staff number] ) = 999 )) 
    ORDER  BY tblmeeting.[meeting date] DESC;
    The False case for the first Iif in both cases is just Iif([field],'Yes','No'). What Data Type is [agentsignoff] and [subsignoff] and what values are in the table for each?

  3. #3
    AmanKaur123 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    47
    The AgentSignOff and SupSignoff have Yes/No datatype. But these fields are only present in tbl_RMS_Paperless table. I want to link it to tblmeeting which has far more records than tbl_RMS_paperless.

    please see attached the spreadsheet. The Sheet1 which shows all the records with no condition( all staff numbers) which is incorrect (as it gives answer in yes or no but there are loads and loads of records in tbmeeting so for then it should be NA)

    The Sheet2 which shows all the records for Aoife which is also incorrect.

    And also in actual tblmeeting has only one record for Aoife with reference 26672 but it appears multiple times in the result.

    The query is wrong and needs to be amended . Any hep will be much appreciated. Many Thanks

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

Similar Threads

  1. Replies: 1
    Last Post: 05-05-2017, 02:32 AM
  2. Populate ListBox from Table(s)
    By Brightspark98 in forum Forms
    Replies: 2
    Last Post: 02-09-2017, 09:38 AM
  3. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  4. Replies: 10
    Last Post: 06-18-2013, 02:00 PM
  5. Populate unbound listbox with VBA
    By usmcgrunt in forum Forms
    Replies: 1
    Last Post: 09-23-2010, 09: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