Results 1 to 6 of 6
  1. #1
    kevin66 is offline Novice
    Windows 10 Access 2019
    Join Date
    Nov 2022
    Posts
    2

    no data returned in my query

    Click image for larger version. 

Name:	Screenshot (22).jpg 
Views:	23 
Size:	83.6 KB 
ID:	49050Click image for larger version. 

Name:	Screenshot (23).png 
Views:	23 
Size:	215.2 KB 
ID:	49051when I run a query with two tables, I do not get any data returned. just the headings of the fields I chose. when I use a single table it works fine. as soon as I bring in the second table. no data, no matter how I mix up the fields. I'm not supposed to change the relationships.
    any suggestions
    this is a very basic query using inner joins. 1tomany
    thanks
    kevin

  2. #2
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Some sample data showing your tables and your SQL

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I think that when using the single table you would only get a result if both the ID's where the same in the from and to user fields?
    That's why you need to link the table twice - to separate the dependency on both joins.

    Edit: I misread your post, but my theory still holds, you will only get a result if both the to and from have data.

    As Alan has asked show us some sample data?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Join Date
    Apr 2017
    Posts
    1,679
    Quote Originally Posted by kevin66 View Post
    Click image for larger version. 

Name:	Screenshot (22).jpg 
Views:	23 
Size:	83.6 KB 
ID:	49050Click image for larger version. 

Name:	Screenshot (23).png 
Views:	23 
Size:	215.2 KB 
ID:	49051when I run a query with two tables, I do not get any data returned.
    You are asking for a list of chat messages from user like "john1", where he is chatting with himself (FromUser is same as ToUser). When there are no such chats, nothing is returned!

    When you want to get the list of chats from certain user with any other user, you have to link another instance of table Users into query. The querystring will be something like
    Code:
    SELECT u1.UserName, c.Message, u2.UserName AS ContactPerson
    FROM (Chats c LEFT JOIN Users u1 ON u1.UserID = c.FromUser) LEFT JOIN Users u2 ON u2.UserID = c.ToUser
    WHERE u1.UserName LIKE "john1"
    Last edited by ArviLaanemets; 11-08-2022 at 12:04 AM.

  5. #5
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    I would recommend that you use an Autonumber PK for a UserID and not Text
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  6. #6
    kevin66 is offline Novice
    Windows 10 Access 2019
    Join Date
    Nov 2022
    Posts
    2
    I figured it out.thanks for the hints

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

Similar Threads

  1. Replies: 4
    Last Post: 02-22-2021, 11:42 AM
  2. Replies: 3
    Last Post: 04-05-2020, 10:00 AM
  3. Replies: 4
    Last Post: 06-14-2016, 09:04 AM
  4. Query data not being returned
    By rperrosx in forum Access
    Replies: 3
    Last Post: 12-20-2012, 05:42 PM
  5. Replies: 6
    Last Post: 09-25-2009, 12:40 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