MS Access Query function that skips records based on criteria - ms-access

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.

Related

Restricting Table to one Row Only Access database

I have created a table which holds a date range like startdate and enddate.This is then referred to in query for the date criteria through a Dlookup. The table is filled through a form which is bound to this table.The problem now is if I change the dates,it creates another record in the table and this creates chaos on the query.How do I ensure that there is only one row in the table?
If you want only one record in table then edit existing record, don't enter dates into New Record row. Set form AllowAdditions and AllowDeletions properties to No.
Could instead of saving dates to a table, keep form open and have report reference form controls for criteria. This would also eliminate DLookup. Domain aggregate functions can slow performance.

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

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.

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]")

Unique values in Report Builder Parameters without rerunning new query

I'm using Report Builder 3 which runs a stored procedure and displays a simple table. Next, we would like to filter based on the first column of data. The first column of data might have 20 rows, and 3 possible values.
How can I make Report Builder display those 3 values in the parameter dropdown, without rerunning a SP or Query from the server?
(Running the SP that obtains the data takes several seconds, and it is not reasonable to rerun another query in order to populate the parameter dropdown)
What I've tried:
1) I create a parameter dropdown and select the column name as values for the dropdown. Instead of getting 3 unique values, 20 rows appears in the parameter dropdown, with duplicates corresponding to the original dataset results. How can I make them unqique?
2) Grouping by the values in the first column. Grouping works, but we would still like to display a parameter dropdown that contains unique values from column one.

VB.NET How to obtain previous record entered from datatable?

I would like to obtain the last record entered in my database and display it in a textbox.
Here is what I tried
Previous_Project_Float_Detail.Text = projectRecordDT.Rows(projectRecordDT.Rows("FloatNo").Count - 1).ToString()
projectRecordDT is my datatable populated with records using mySqlDataAdapter.
In my database, I would like to retrieve the last record of the column FloatNo.
Usually I am able to retrieve this by creating a new datarow. But how do I obtain it efficiently without having to loop the records every time by using datarows?
I have managed to solve my own question because I misplace a parenthesis with the column name.
The correct way is
Previous_Project_Float_Detail.Text = projectRecordDT.Rows(projectRecordDT.Rows.Count - 1)("FloatNo").ToString()
The column name is after the row count. Not inside.
Also, this only works if the order of the records is already correct in your database.