473,402 Members | 2,061 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,402 software developers and data experts.

Query/Report for most recent journal entry

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 21438
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 Expert Mod 4TB
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
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 Expert Mod 4TB
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 Expert Mod 4TB
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
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 Expert Mod 4TB
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 100+
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 Expert Mod 8TB
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
zmbd
5,501 Expert Mod 4TB
[edit] using the long date format is [/edit] Certainly one solution and one I use myself for certain history logs in some of the databases we use inhouse; however, from the SQL provdided in #4 I get the impression that Jamaher is trying to relate the information between two or more tables and somewhere in the database there is either a missing relationship between the tables or some other logic error...

Once again... Jamaher having the basic table design and the relationships between the tables would be most helpful. I don't need actual data... just the table names, the field names, and any established relationships between the tables. Without that information I simply will not be able to provide anymore help with this question.

-z
Jul 5 '12 #11

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

Similar topics

6
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...
1
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...
2
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...
1
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 |...
0
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...
3
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...
5
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...
3
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...
1
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...
3
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.