473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to show last date on a continuous form including blanks?

Hi everyone,

Thanks in advance for any help you can give me.

I have a table "tbl_CHcontactlist" connecting in a 1-many relationship with another table "tbl_CHchecklists".

I have build a continuous form that I intend to show all records from tbl_CHcontactlist" on. My manager has asked me to also show the most recent date a checklist was completed for each care home, however, it also needs to show blank fields where a checklist has not yet been completed. Does anyone have any suggestions on the best way to go about this?

I have tried building a query using the max function but can't seem to get it to work right and simply adding the date field from the "tbl_CHchecklist" table makes it so I can't see all the records from "tbl_CHcontactlist"
Aug 13 '19 #1

✓ answered by twinnyfo

First, let's make some assumptions on naming conventions. You will have to change the field names to make this work properly.

Expand|Select|Wrap|Line Numbers
  1. tbl_CHcontactlist
  2. CHcontactID
  3. ContactEMail
  4. ContactAddress
  5. etc.
and

Expand|Select|Wrap|Line Numbers
  1. tbl_CHchecklists
  2. CHcontactID
  3. ChecklistDate
  4. etc.
To find the most recent date for each Care Home:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.     CHcontactID 
  3.     Max(ChecklistDate) AS LastDate 
  4. FROM 
  5.     tbl_CHchecklists 
  6. ORDER BY 
  7.     CHcontactID;
I presume you have probably gotten that far....

But, you want to join that query (which can be a subquery in your main query like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.     tbl_CHcontactlist.CHcontactID 
  3.     qsubChecklists.LastDate
  4.     etc. 
  5. FROM 
  6.     tbl_CHcontactlist 
  7. LEFT JOIN (
  8.     SELECT 
  9.         CHcontactID 
  10.         Max(ChecklistDate) AS LastDate 
  11.     FROM 
  12.         tbl_CHchecklists 
  13.     ORDER BY 
  14.         CHcontactID) 
  15.     AS qsubChecklists 
  16. ON 
  17.     tbl_CHcontactlist.CHcontactID = qsubChecklists.CHcontactID;
"I think" that this will give you a list of all the Care Home IDs, and the most recent checklist. If there is no checklist date, then it will merely be blank (Null).

It's often difficult to write a query without the tables before me to test it.

Hope this hepps!

3 904
twinnyfo
3,653 Expert Mod 2GB
riccal90,

Welcome to Bytes!

You may have to create a query to find the most recent checklist for all care homes and left join it to your table in a new query with the criteria that the Date either equals that max date or is null.

Hope this makes sense and hope it hepps.
Aug 13 '19 #2
Thanks Twinnyfo, the first part certainly makes sense as I can use a max query to find the latest date for each care home. However you mention left joining onto the table... how would I go about doing that?
Aug 13 '19 #3
twinnyfo
3,653 Expert Mod 2GB
First, let's make some assumptions on naming conventions. You will have to change the field names to make this work properly.

Expand|Select|Wrap|Line Numbers
  1. tbl_CHcontactlist
  2. CHcontactID
  3. ContactEMail
  4. ContactAddress
  5. etc.
and

Expand|Select|Wrap|Line Numbers
  1. tbl_CHchecklists
  2. CHcontactID
  3. ChecklistDate
  4. etc.
To find the most recent date for each Care Home:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.     CHcontactID 
  3.     Max(ChecklistDate) AS LastDate 
  4. FROM 
  5.     tbl_CHchecklists 
  6. ORDER BY 
  7.     CHcontactID;
I presume you have probably gotten that far....

But, you want to join that query (which can be a subquery in your main query like this:

Expand|Select|Wrap|Line Numbers
  1. SELECT 
  2.     tbl_CHcontactlist.CHcontactID 
  3.     qsubChecklists.LastDate
  4.     etc. 
  5. FROM 
  6.     tbl_CHcontactlist 
  7. LEFT JOIN (
  8.     SELECT 
  9.         CHcontactID 
  10.         Max(ChecklistDate) AS LastDate 
  11.     FROM 
  12.         tbl_CHchecklists 
  13.     ORDER BY 
  14.         CHcontactID) 
  15.     AS qsubChecklists 
  16. ON 
  17.     tbl_CHcontactlist.CHcontactID = qsubChecklists.CHcontactID;
"I think" that this will give you a list of all the Care Home IDs, and the most recent checklist. If there is no checklist date, then it will merely be blank (Null).

It's often difficult to write a query without the tables before me to test it.

Hope this hepps!
Aug 13 '19 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Deano | last post by:
Here's a good one that keeps defeating me... I have a continuous form that has a date textbox as one of the controls. The user can choose any date they like including one they have already...
4
by: Bob Alston | last post by:
I have some dates which show in a continuous form, multiple rows at a time. I would like to color the background yellow, or the text yellow or some color other than black that would stand out,...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
6
by: balancetotal | last post by:
Creating a running sum in continuous form in Access 2003 -------------------------------------------------------------------------------- Hello: I have three forms on my user-interface. ...
13
by: eighthman11 | last post by:
using Access 2003 and sql server version 8.0 Hey everyone. Created a text box where the user types in an Inventory number and it takes them to that inventory number on the contimuous form. The...
12
by: hedges98 | last post by:
Hello! I am having a bit of trouble trying to figure out how to create a query based on data retrieved from a continuous form. The table it is based on looks like this: Table = tbl_Appointment...
2
by: Ian Anderson | last post by:
Hello there, SO i have the followign VB code in my continuous form... 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few...
10
by: mfarley | last post by:
Hello there, I'm new to access and I have a simple question. I'm writing a form in MS Access 2007 with a date field, I'd like the field to be populated by the last date entered instead of today's...
1
by: colpamia | last post by:
Hello! I have a lead management database with a main form being a "list view" of all the leads in the database. This form gives brief information on leads including company, contact name/number,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.