SSRS Why is this relatively simple IIF statement returning an intermittent error? - reporting-services

I have one table that holds all data. This table includes unique ID field ("ID"). I have another table that records when each record from the first table is processed. This table has a field ("ID") in which the unique ID from the is inserted when the record is processed. The second field here is the timestamp for when the record was processed.
In my report I list all of the records in the first table for the last 24 hours. I include a final textbox on the end of the row, which is labeled "Transferred?", and should have a value of either "Yes" or "No".
The formula I am using to calculate the last field is:
=IIf(IsNothing(Lookup(Fields!ID.Value, Fields!ID.Value, Fields!UTC_PROCESSED_DATE.Value, "TransferredData")), "No", "Yes")
I compare the ID fields in both tables and if the ID of the current record is not in the 2nd table, the output is "No", and if it does exist the output is "Yes".
Generally this works fine. However, I am having intermittent issues when the first record in the list has a value of "#Error".
Why is this relatively simple IIF statement returning an error?
Additional information: This does not seem to be limited to the top row, as I've seen one result after a refresh, the record previously on top had the Error message still had the error. Another refresh and that record was fine, and the top again had an Error. The Error does not always show up, but is very common.
Related, but not duplicate question: IsNothing Error
The True/False answers are strings rather than calculated values that attempt to access non-existing records.

Related

MS Access Query function that skips records based on criteria

I am trying to test query function. IIf(IsNull([LTCMPlanSubmitted]),Date()-[LTCMPlanDue],[LTCMPlanSubmitted]-[LTCMPlanDue]) - This query runs successfully. Thing is it fills in data in records where technically should be blank for the field because the issue was cancelled.
Lets say the function in the query fills data in 8th field over in the table. can the Criteria be set up to look at ANOTHER field in the table?
Function is updating data in [DaysPlanlate] field - If value in a record in [OverallStatus] Field is "Closed-Cancelled" for THAT record then I want it to stay or be Blank. Is this possible to do? or should I be modifying the original function in the query instead? can you do "Nested Ifs" in Access?
I tried simple statement of [OverallStatus] = Not "Closed-Cancelled" in the Criteria but it just updated 0 rows
i was expecting the records that were Closed-Cancelled to become Blank. if i leave the query where it is it will just continually count up as each day passes.

MS Access Control Source DLookUp

I haven't been able to make a DLookUp function work in an Access report. I can't figure out what I'm doing wrong.
The report is getting its dataset from a query called Aggregate Query. This query builds a dataset from 20 related tables using CustomerID as the primary key in one table and as a foreign key in the other 19. CustomerID is specified by an open Form with the desired customer's record displayed, including the CustomerID field.
This means Aggregate Query has several rows for one specific CustomerID. One field, Needs Notes, will have the same content on every row. What I'm having trouble with is getting only one of these rows displayed in the subreport, and subsequently on the parent report.
If there are six rows, say, in Aggregate Query, then the same Needs Notes field is repeated six times. I want it to appear only once in the subreport.
I couldn't choose only the first row from Aggregate Query. If this can be done that'd be great. I don't know.
So I created another query, Need-notes Only Query, which always gives me only one row every time. So far so good. Now I want the contents of the Needs Notes field to appear all by itself in the subreport. To do this I selected the text box and entered the following into the Control Source parameter:
=DLookUp("[Needs-notes Only Query]![Needs Notes]","Needs-notes Only Query")
No dice. I get six rows saying #Error.
Is there a way I can get just one row of the Needs Notes field into my report?
Split field and table names:
=DLookUp("[Needs Notes]","[Needs-notes Only Query]")

Form set to be used for data entry attempting to create duplicate records causing error

I have a form that is set to be used for data entry that is not working. When the form opens it is blank however when anything is entered in any field the primary key field (visible but not editable on the form) sets itself to a value that is already in use. The rest of the fields on the main form remain blank however I have subforms that fill with values corresponding to the primary key. The source of the form is a single table that is linked to the database from the backend. The table has no missing records. The exact error I get when I try to then close the form is:
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."
The same error is occurring on another form that is then used only for updating records. The error appears anytime anything is entered into a field on a subform.
Any ideas are appreciated!
Thanks
As I understand, Access inserts automatically new value to autonumber field, and this value already exists. If so, run compact & repair, it will set autonumber next value to max in field + 1
Access generates new value for autonumber fields using internal counter, not maximum value. This internal counter can be set by inserting any value to autonumber field using, for instance, INSERT SQL statement, also it can be done in some cases during editing data in forms with linked subforms. Internal counter resets to last inserted value + 1. After compact & repair counter resets to actual maximum value +1.

Sorting records on a form in MS Access 2010

I had a question last week about how to do a sort of ascending ID numbers by year for a SQL query.
Doing a secondary sort by year in a SQL query
I followed those instructions and the result was great for my table. The data in the resultant query was used to create a table that was then linked to a form. Unfortunately, as I add new records to the table, am I seeing that the sort is not respected after data entry (that is, new records are automatically displayed first when browsing records with the form instead of last). Is there a way to do a sort with ascending ID numbers and year within the form itself? When I try to use the ORDER BY year (date) expression in the form properties I'm getting an "undefined function in expression" error.
Since you already create a new table from the data, you could add a new column to that table containing the "year(date)" result. That way, you have a real column you can ORDER BY on. (ORDER BY yearcol, id)
When inserting, fill it with the current year.

Calculation query in Access produces null result all the time

I am trying to create a community database in Access (2003 preferably). Part of the main table has several fields relating to personal relationships, with field names such as "Partner", Child_LT_16", Child_GT_16", "Parent", "Sibling" etc. On the entry form each of these fieldu can have a number entered for the number of each kind of relation. Each field is defined as "Integer". The entry and normal display via a form is OK for this basic operation. However I now want to have an additional field to be ised on Forms and Reports that show the total number of relations for each record.
I have constructed a query, with a calculated field of the form
Total_Relations:[Partner]+[Child_LT_16]+[Child_GT_16]+[Parent]+[Sibling]
This query doesn't throw any errors and runs without problems, BUT it doesn't return any value for any record. In all cases the Total_Relations column stays blank (empty).
It is as though the query engine is seeing all the field values as EITHER empty (some are empty others have values usually between 1 and 3, virtually all have a numeriacl value somewhere in the various relations fields) OR taking the field value as text and giving it a NULL value (but the fields are defined as Integers.
I have tried various things including using VAL([Partner]) etc. in case the fields were being taken as Text. In this case any record that had any NULL field threw-up an error message, only records where all relevent fiels had numeric values did not throw the error, but they still did't show a total (or any) value either.
I have tried recreating the query gain, from scratch, several time, but with the same result each time
I have done this type of calculation loads of time before without problem, but this one has me climbing upm the walls.
Any suggestions from anyone?
PLEASE............
In MS Access, if you add two (or more) values together and any one of them is null, then the result is null.
You need to check is each value null, or make the fields not null-able, so there will be zero values in there if nothing is entered.
Have a look at this for working with Nulls in MSAccess, Tip #5 is the one you want