Results 1 to 12 of 12
  1. #1
    Seattle5674 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    11

    Access query return DOB

    Hello,

    I am looking to make this query return the AVG DOB per house name.

    When I run the query I get this mesage with zero results.

    I want the query to just return the single house name with the DOB from the clients table.

    Any suggestions?



    Click image for larger version. 

Name:	DOB Query.jpg 
Views:	18 
Size:	103.2 KB 
ID:	47288

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    are you sure HouseID and ClientID are the same?
    Seems like t.HouseRooms would have a ClientID field.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    If al l you want is records to be returned, don't create a make table query; use Select instead. If you get no records, then there is nothing in the fields that are joined that are equal. Also, you should not store calculations in tables (e.g. age), rather, calculate in forms and reports when needed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I think actually you should add a HouseID_FK (foreign key) to the Clients table and join that to HouseID (notice the field name has no space in it) in tblHouseRooms (again no space or special characters in table name) as you would have multiple clients living in the same house.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Seattle5674 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    11
    Click image for larger version. 

Name:	200.png 
Views:	11 
Size:	22.2 KB 
ID:	47291
    Thank you Gicu, I did that. However, it is returning zero results. I have a screenshot of the design query. Is there something I need to fix there?

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Can't say without seeing your data but you should not have the last field in the query.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Please see attached sample.

    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    Seattle5674 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    11
    Thanks Cicu, that worked. Except how do I format decimals? the results are returning many decimals.

    I want to update at design level not table level.

    Click image for larger version. 

Name:	age.png 
Views:	11 
Size:	4.0 KB 
ID:	47294

  9. #9
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Open the query in design view, select the calculated field (Age) then go to Properties (or right click on the fields and select properties in that menu) and under format select Fixed and In Decimals select 0 (or 1 or whatever you want).
    Click image for larger version. 

Name:	Screenshot 2022-02-18 133741.png 
Views:	11 
Size:	90.8 KB 
ID:	47295
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #10
    Seattle5674 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    11
    Click image for larger version. 

Name:	2000.png 
Views:	9 
Size:	7.0 KB 
ID:	47296
    I tried that but the decimal places box is not showing up under properties.

  11. #11
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Fixed not Standard.
    Otherwise just wrap the whole expression in FormatNumber() function:
    Code:
    AGE: FormatNumber(Avg(DateDiff("yyyy",[ClientDob],Date())),2)
    https://support.microsoft.com/en-us/...7-311ab6ebf43b
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  12. #12
    Seattle5674 is offline Novice
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    11
    that did the trick. Wow, its much easier to just wrap in the code that mess with properties.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2018, 10:17 PM
  2. Replies: 24
    Last Post: 09-16-2018, 04:02 PM
  3. Replies: 6
    Last Post: 04-04-2017, 02:50 AM
  4. Replies: 2
    Last Post: 03-16-2016, 07:59 AM
  5. Access Query: Return Month Name and Year
    By PhatRam32 in forum Queries
    Replies: 7
    Last Post: 05-13-2013, 05:28 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