473,902 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query/Report for most recent journal entry

13 New Member
Hello all!

I have a rather large database for ongoing projects at my office. There is a form that is used to enter basic information about each project, and this form contains a subform to record journal entries for each project. The system assigns a random autonumber to each project, and the subform uses the same autonumber to associated each journal entry with the correct project.

The subform conatins the following fields: Autonum, Date, and Journal_Entry. Everything has been associating properly, but when I try to create a report to show the most recent journal entry for each project, I have a few problems.

The main problem: the system will show the correct date(the most recent date a journal entry was made) but will show the wrong journal entry. The journals appear to end up in alphabetical order. For some reason, the association between the date and its respective journal entry is lost. Any thoughts on how to fix this?
Jul 3 '12 #1
10 21471
jmaher196
13 New Member
Sorry, I should also mention that I have been using the Group/sort feature to put the most recent date on top in the report.
Jul 3 '12 #2
zmbd
5,501 Recognized Expert Moderator Expert
There might be an issue in how the relationships in the DB have been defined (ribbon, database tools, relationships).

Would be helpful to have the tables and their fields:

Expand|Select|Wrap|Line Numbers
  1. Table_One:
  2. [tblone_pk] autonumber, primary key
  3. [somefield] text(50),required,indexed
  4. [yetanother] long, not required, not indexed
  5.  
  6. Table_Two:
  7. [tbltwo_pk] autonumber, primary key
  8. [tblone_fk] long, foriegn key to Table_One 1:M
  9. [otherfileds] type and information.
and the SQL for your queries behind the reports:

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.    Table1.ID_t1, Table1.date_t1, Table1.something_t1
  3. FROM 
  4.    Table1;
thnx
z
Jul 3 '12 #3
jmaher196
13 New Member
I am not allowed to show you the actual tables, as the information contained in them is highly confidential. I apologize for that, but I can give you the SQL for the In-Process Project query:

(The very large IIf statement is for another part of the query that works fine. Again, sorry if it is confusing)

Expand|Select|Wrap|Line Numbers
  1. SELECT Test_Table_for_sorting.Job, Test_Table_for_sorting.Type, Test_Table_for_sorting.Initiative, Test_Table_for_sorting.Project_Name, Test_Table_for_sorting.Customer, Test_Table_for_sorting.Project_MGR, Test_Table_for_sorting.Tech_Lead, Test_Table_for_sorting.[Est Completion], Test_Table_for_sorting.Status, JournalEntry.Date, JournalEntry.Journal_Entry, IIf([MS1AED] Is Null And [MS1EED] Is Not Null,[Milestone 1Type],IIf([MS2AED] Is Null And [MS2EED] Is Not Null,[Milestone 2 Type],IIf([MS3AED] Is Null And [MS3EED] Is Not Null,[Milestone 3 Type],IIf([MS4AED] Is Null And [MS4EED] Is Not Null,[Milestone 4 Type],IIf([MS5AED] Is Null And [MS5EED] Is Not Null,[Milestone 5 Type],IIf([MS6AED] Is Null And [MS6EED] Is Not Null,[Milestone 6 Type],IIf([MS7AED] Is Null And [MS7EED] Is Not Null,[Milestone 7 Type],"Pending"))))))) AS [Current Milestone], IIf([MS1AED] Is Null And [MS1ESD] Is Not Null,[MS1EED],IIf([MS2AED] Is Null And [MS2EED] Is Not Null,[MS2EED],IIf([MS3AED] Is Null And [MS3EED] Is Not Null,[MS3EED],IIf([MS4AED] Is Null And [MS4EED] Is Not Null,[MS4EED],IIf([MS5AED] Is Null And [MS5EED] Is Not Null,[MS5EED],IIf([MS6AED] Is Null And [MS6EED] Is Not Null,[MS6EED],IIf([MS7AED] Is Null And [MS7EED] Is Not Null,[MS7EED]))))))) AS [Est Milestone End Date]
  2. FROM Test_Table_for_sorting INNER JOIN JournalEntry ON Test_Table_for_sorting.AutoNum = JournalEntry.AutoNum
  3. WHERE (((Test_Table_for_sorting.Job) Is Not Null) AND ((Test_Table_for_sorting.Type)<>"Prog Mgmt" And (Test_Table_for_sorting.Type)<>"Alligator") AND ((Test_Table_for_sorting.Initiative) Is Not Null) AND ((Test_Table_for_sorting.Status)="In-Process"))
  4. ORDER BY JournalEntry.Date DESC;
  5.  
Jul 3 '12 #4
zmbd
5,501 Recognized Expert Moderator Expert
We don't need the actual data...
What I'm after is the structure of your DB as shown in the generic example in my post.

Wow that's a nest of IIF... that'll take a second to read and see where and if there is any relationship between the records.

Once again... we don't need the data just the table structure and the actual assigned relationships between the tables.
-z
Jul 3 '12 #5
zmbd
5,501 Recognized Expert Moderator Expert
From your SQL, here's what you given me to look at for a table structure:

Expand|Select|Wrap|Line Numbers
  1. Test_Table_for_sorting:
  2. [AutoNum]  (PK: autonumber field, index, no duplicates)
  3. [Job] (text)
  4. [Type] (text - 1:M (?) with table "type")
  5. [Initiative] (FK: text - 1:M (?) with table "Intiative")
  6. [Project_name] (text)
  7. [Customer] (FK: text - 1:M (?) with table "Customer")
  8. [Project_Mgr] (FK: text - 1:M (?) with table "Employees")
  9. [Tech_Lead] (FK: text - 1:M (?) with table "Employees")
  10. [Est Compleation] (Date, short)
  11. (.... then a whole series of fields named "Milestone... type)
Expand|Select|Wrap|Line Numbers
  1. JournalEntry:
  2. {missing a primary key for this table}
  3. [AutoNum] (FK: numeric, long - 1:M with table "Test_Table_for_sorting)
  4. [Date]  (date, short)
  5. [Journal_entry] (text)
How are these two tables related? Is this on the [AutoNum] field? If so, then I suspect they will not sync. When using autonumber fields, the field creates value that is independent from other tables. There needs to be a foreign key field somewhere and a relationship established.

Having the missing field properties would be helpful.

Having the DB table structure as I have shown in my first post and above will be helpful.

Once again... just as with the SQL... we don't need the actual data... we just need the skeleton and the tendons so to speak.

The SQL also gives the impression that the database may not be normalized enough; however, that is just a guess on my part.

Something to note: “Date” is a reserved word… using this as a field name may create problems for you in the future… you’d be surprised how many common words are reserved words and using them for field names and VBA variables will cause issues.
-z
Jul 3 '12 #6
jmaher196
13 New Member
To fill in the missing properties:

Test_table_for_ Sorting:
Autonum: is a long integer autonumber, new values are random, Indexed with no duplicates.
Job: Is a text field that is not indexed. The basic outline for assigning Job# is SB-##-###. The first 2 #s represent the year the project was started, the last 3 #s represent the job number for that year. Ex SB-12-001
Type: A text field that is not indexed. The values are listed in a different table
Initiative: Same as TYPE
Project Name: A text field that is not indexed.
Customer: A text field taking data from another table. It is indexed. In the other table Customer is the primary key, linked to customer in the main table.
Project_MGR and TECH LEAD: Both are linked to a table listing all employees. Text fields that are not indexed.
Est. Completion: A Date/Time field, short date.

The milestone info within the IIF statement relates to a whole series of fields that track the current milestone and display it with the estimated end date for that milestone.

As far as the Journal Entry table goes:
Autonum: A number field linked to Autonum from Test_table_for_ sorting. It is indexed with duplicates
Date: A date/time field using short date
Journal_Entry: A text field for the actual journal entry.

Thoughts?
Jul 3 '12 #7
zmbd
5,501 Recognized Expert Moderator Expert
It will take me a few moments to think about this.

I edited my post in #6 to reflect the information proved in #7 for the tables.

From what you've stated, it does not appear that there is a primary key in the JournalEntry table. Therein may be your issue.

The muliple Milestone fields worry me a tad about the normalization of the DB you're working with.

-z
Jul 3 '12 #8
ariful alam
185 New Member
In your database system, the journal entry table entry each date like DD/MM/YYYY HH:MM:SS:xxx. when we enter date it basically takes the DD/MM/YYYY's value and other left like 00:00:00:000.

if you can entry with HH:MM:SS:xxx then, you can sort the data in descending order easily and get every Projects last journal entry.
Jul 5 '12 #9
Rabbit
12,516 Recognized Expert Moderator MVP
You can't post the actual data but can you post some fake data and the results you would want from said data?
Jul 5 '12 #10

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

Similar topics

6
8183
by: Brad Kent | last post by:
I have a problem that can be summarized with a simple table having the following 3 columns: timestamp userid status The table is constantly being updated. I'd like to get the most recent row for each userid present in the table? What pray tell is the trick?
1
3443
by: Tim Graichen | last post by:
Good morning, I have a sub-form that displays records from a table as a continuous form. The table has several hundred records, but the subform only displays five or six records. The records do include a date field. How can I force the sub form to display the most recent dates by default, verses forcing the user to scroll through all of the records to the bottom of the form in order to view the most recent entry or to add a new entry...
2
3881
by: Shaiguy | last post by:
I have a table containing the following fields: ProjectUpdateID (PrimaryKey) ProjectID UpdateDate I would like to create a Query in Ms Access 2000 which will return me the most recent 2 records (and also show the above 3 fields) So suppose the table looks like this:
1
1511
by: getyourbiglobster | last post by:
hello- i have a sample database that i want to query for most recent SAMPLE, min SAMPLE_RESULT, and max SAMPLE_RESULT. the table is orgainzed as such: SAMPLE | SAMPLE_DATE | SAMPLE_TIME | SAMPLE_RESULT any ideas?
0
831
by: Nicolas | last post by:
How can I assign a contact to my new journal entry in Outlook 2003 within an Add-in that I'm creating in dotnet? I'm able to create my Outlook Journal Entry fine but not able able to assign it to a Contact. I want to be able to see from the activity tab in the contact page the entry I just created for this contact. Thanks for the help.
3
1869
by: manny | last post by:
Problem: how to have query show only most recent records. This query shows all exams in 2005 for particular individual (grades not shown to avoid embarrassing John Slacker!): SELECT examhistory.coursekey, students.userid, students.firstname, students.lastname, examhistory.examdate,coursekeylookup.examdescription FROM students, examhistory, coursekeylookup AND students.userid='1234567'
5
13251
by: bill1313 | last post by:
I'm currently working on a component tracking file and we are using an hour meter query to always have up to date information. My problem is that I need the hour meter query to display the reading of the most recent date for each equipment number. My columns are: EQUIP_NO DATE_READING CONDITION LIFE_TO_DATE I want a single SQL query that, given an EQUIP_NO, returns only the most recent DATE_READING, CONDITION and LIFE_TO_DATE. I have...
3
1843
by: AnthonyT | last post by:
Hi All I have a major problem with an access query and I am near the end of my tether! I have taken over a project with a badly built access database and as resources are not available to start over I have to make do and cobble together a fix. DB is design to record customer reviews . It was built as 1 table with 1 line per review. So as you can imagine you can have several reviews for the same customer over time.
1
2411
by: lutz | last post by:
I fully admit, I am begging for some help. I am at the mercy of anyone's generous nature. I wish I had a template to follow for this one. I thank you in advance for anyone's advice. Maybe this is not possible to do in one query? I know I screwed up the Where clause, and probably the placement of the subquery SELECT statements, but since I am doing this out of design view in Access, the SQL with all its glorious and () automatically...
3
3494
by: suexicano | last post by:
Hi - Thanks for your help with this one. I have a table that records transactions for individual invoices, and I want to pull the most recent transaction based on the entry date. Using the example below, I want to write a SQL statement that would only pull records that have ID 3,4, and 9 (as those records have the most recent EntryDate for each individual Invoice). Here is an example of the transaction table: ID InvoiceNo ...
0
9997
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9845
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10870
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4306
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3323
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.