DLOOKUP function multiple criteria - ms-access

I am creating a database where I want to manage three tables: files, client, meeting_dates. Each file has multiple meeting dates and refer to multiple clients.
Two of the meeting dates are the most important dates, the date of signing the contract and the date of closing the file and these have specific strings set in another column in the dates table (sign and close)
All three tables are linked by the ID of the file (fileID), which is unique value.
I want to generate a report based on the files table which will contain, for every individual file, the date of signing the contract and the date of closing the file, the names of the parts and the number of parts.
I don’t want to use subreports, only text boxes, because the report is intended to be a letter with sentences and the formulas will be inside the sentences. An example of the sentence is – The case number “Case_number” was signed on “Date” with the clients “Clients” and closed on “Date.
The formula I have tried is.
=DLookUp("[Date]";"[tbl.Dates]";"[fileID]=" & [fileID] And [type]='sign')
but it doesn't show any date at all

Try this with corrected concatenation:
=DLookUp("[Date]";"[tbl.Dates]";"[fileID]=" & [fileID] & " And [type]='sign'")

Related

Filter by values from csv file in Tableau

I've get a dimension in my Tableau workbook called discount codes. This dimension holds 30,000 strings. Also I've get separate csv files that hold hundreds of discount codes.
In Tableau I want to filter out the values from a single csv file.
I have tried to create a filter and just paste the discount codes in a list:
When I select every single value manually it works. But when I paste the whole list Tableau can't match the discount codes.
Is there any way to filter the values without selecting every single value?
You could do this using Excel (for speed) and a calculated field. Use Excel to write the calculated field formula. You already have the list of discount codes in Excel, use this to create a calculated field, a giant CASE statement.
Assuming your list of exclusions starts in cell A1, cell B1 would be
="WHEN '"&A1&'" THEN 1 "
The formula in cell B2:
=B1 & "WHEN '"&A2&'" THEN 1 "
Drag that formula to the end, and you should then have the contents of a large case statement. Copy the final cell formula as values, then copy the text into a Tableau calulcated field.
Start the calculated field with:
CASE [Discount Codes]
*pasted value*
END
All being well, you can use that calculated field as a data source filter and exclude 1.
Note I haven't tested this so watch out for bracket errors, etc.

How can I group data by matching identical cells in same column then counting instances of a related column?

data output
I am pretty new to Webi and am having an issue creating a variable. I'm trying to check if there is more than 1 email address for each entity legacy account number and if 1 of the contact names contains "Annual Report". So when I flag each entity legacy account number for no email only the ones without a contact name that contains "Annual Report" will be pulled. In the example above only the yellow groups should be called no email. Right now all of them are being pulled into no email. I have tried using if and match as those are what I am most familiar with. Does anyone have any suggestions?
There are number of ways you could do this. I am going to give an example using two variables, but you could easily combine them into one.
Has No Email Var=If(Match(Upper([Contact EmailAddress]); "NOEMAIL*"); 1; 0)
Annual Report Contact Name Var=If(Match(Upper([Contact Name]); "ANNUAL REPORT*"); 1; 0)
Then you would apply a report filter with two components...
Has No Email Var = 1
AND
Annual Report Contact Name Var = 0
Let me explain a few things...
The purpose of the Upper function is the Match function is case sensitive. If you know your email address are always lower case then you could remove that the Upper function and have it match on "noemail*".
It is significant that I only have a asterisk ("*") at the end of the string being sought. That will only find a match where the corresponding column value starts with that string. If you want it to be true whenever the string is found anywhere in the column being searched you would be asterisks on both ends.
You could also put limiting criteria in your query filter. But here is where thing can get confusing. Within the query filter you can choose the Matches pattern operator. However, the wildcard character is different ("%" rather than "*") and you do not put double-quotes around your search text. So you would have some thing like this...
Contact EmailAddress Matches pattern noemail%
AND
Contact Name Different from pattern Annual Report%
I am sure you noticed I didn't convert the search text to uppercase. In the Query Panel Web Intelligence is case-insensitive and would likely follow the case-sensitivity of the database of the source data. All of our databases are case-insensitive so if yours is case-sensitive you may need to play around this this a bit. Or just go with the approach of creating the variables and report filters as I initially laid out.
If you want a wildcard for a single character rather than multiple characters (which is what "*" and "%" will do) you need to use a "?" within your variable definition or a "_" in your query filter.
Hope this helps,
Noel

Combining DMax with Dlookup to find value from last row created

I have an access database that tracks reports numbered in this way:
NNN-[two digit site code]-YY0000
The “0000” is a sequential number assigned as the reports are issued.
Examples are: NNN-SD-180001, NNN-MA-180002.
tbl_NNN stores the records.
NNN_ID is the column that stores the report numbers.
The report numbers are manually assigned, so we must keep track of the last assigned number to prevent “duplicating” the sequential 0000 number. Since users do not have visibility to the entire table of assigned numbers, they do not know which is the last number assigned. To assist them, their dashboard/form has a label that displays the last number issued. The problem we have is that the label only shows numbers that include the SD site code, MA numbers are not displayed.
My solution was to add a column named “Date_Created”, which adds a =Now() time stamp whenever a new row/number is created in the table. With the timestamp, I then intended to use Dmax to display the report number that corresponds to the last row created, regardless of the report number.
I know what I need is a combination of DLookup and Dmax, but what I came up with displays
"#Error"
in the label.
=DLookUp("NNN_ID","tbl_NNN","[Date_Created]=" & DMax("[Date_Created]","tbl_NNN"))
Am I writing this correctly?
You are close, but you must use single quotes (or unreadable expanded double quotes) for the embedded DMax:
=DLookUp("NNN_ID","tbl_NNN","[Date_Created] = DMax('[Date_Created]','tbl_NNN')")

Exporting Data with a Specific Date

Scenario:
I have a single table in access 2007 with few columns and several thousand records which I have imported form a CSV file via a “DoCmd” statement.
What I want:
I want to export these records but on a basis of specific field content and with another column’s date basis. i.e. I want to export the records with the “EQ” ( content of a columns field “SERIES”) and with a date which is one amongst the many dates the column have.
The “SERIES”, I have defined in “Criteria” in my query and it is working fine as the “SERIES” remains the same every day.
Issues:
The problem is with the date that changes every month and I cannot define or hard-code it in anywhere.
Query is working fine with the file where there is no date, but with a date, it is an issue.
Question:
Can we put a user define textbox, where user can define the date and that date will be taken by the query and will return the records with that defined date? In addition, “SERIES” is already defined in query so the result will be exact.
I use the following statement for exporting the data:
DoCmd.TransferText acExportDelim, "NewFnoSpec", "fnoquery",
"C:\Users\welcome\Desktop\Output.txt", True
Using the following 'WHERE' clause as a starting point to select records for one specific date:
WHERE (((Table1.SERIES)="First") AND ((Table1.MyDate)=#4/4/2014#));
You can prompt the user to enter a date by using:
WHERE (((Table1.SERIES)="First") AND ((Table1.MyDate)=[Enter Date]));
If there was some pattern or rule as to the desired date (i.e. first day of prior month, first Monday of prior month, etc.) you could structure the 'WHERE' clause to handle that without a prompt.
Thank you for your reply and an answer. Your answer is quite helpful. I have tried a little easier way and it worked for me. I put a text box named txtexpdate, on the form and in the query ( design mode ), in criteria I have put this :
Like "" & [Forms]![Futures]![txtexpdate] & ""
This is working fine at this juncture. And thank you once again for your efforts to answer my question. Hope this also will help others as an option to this problem.
Regards
Achal

Input mask in Access database

I have a field with a customer ID that should be in the format of C0000000001, where it has a letter at the start and up to 10 numbers after the letter with leading zeros between the letter and the number. I want the users to be able to put in C1 and have the table save C0000000001 or C1234 and have the table save C0000001234.
I want the restriction to be on the hard data in the table. The table should contain the full customer ID but I only want the users to have to enter the C and the number of the customer when entering/searching for customers. I am using Access 2010.
I believe that the first character will always be a C, but either way, it would only be one alpha character if it wasn't.
I understand what you are saying, but the majority of the data (thousands of records) are going to be from another system that stores them that way. Doing it this way limits my margin of error. Otherwise, exports from the other system will need to be manually changed prior to being imported into the database and vice versa.
Searching would only be on existing records that will be saved in the C0000001234 format, but I would like user to be able to omit the leading zeros when entering the search criteria.
This question, combined with your previous question here, suggest to me that you are trying very hard to have the data structure in your Access database exactly match the legacy system from which you receive bulk updates. That may not be necessary, or even desirable.
For example, instead of maintaining the CustomerId as Text(11) (as in the old system) you could store it in your Access database as
CustomerIdPrefix: Text(1), and
CustomerIdNumber: Long Integer or perhaps Decimal if the numeric part really can exceed 2,147,483,647
Your Customers table in Access could also include a calculated field named CustomerId as
[CustomerIdPrefix] & Right("0000000000" & [CustomerIdNumber], 10)
to give you a single 'C0000012345' value for display purposes.
For searching, your form could have a Text Box for the Prefix (default value: 'C') and another text box for the numeric part. The search could then use a condition like
[CustomerIdPrefix] = txtPrefix.Value AND [CustomerIdNumber] = txtNumber.Value
or, if the user wanted to create a Filter on the Form (or Datasheet View) it would probably be sufficient to just filter on the number part.
If you ever needed to feed information back to the legacy system you could just export a query that includes the [CustomerId] calculated field (and omits [CustomerIdPrefix] and [CustomerIdNumber]) and you'd be fine.
My suggestion would be to use forms with associated queries using the FORMAT function.
You do need to clarify where you want this implemented, but I'm going to assume you have a table set up and that you would like to be able to enter/search data from a form.
I'll create one form for input frmAdd. For the input form, I created a query that would run when a button on the form was pressed. Add two text boxes newID and newOther to the forms which are unbounded but which the user can use to enter data. The query will then pull that data and append it to your table in an altered format. Here's the SQL for that query:
INSERT INTO Customers ( [Customer ID], [Other Field] )
SELECT Left([Forms]![frmAdd]![newID].[value],1)
& Format(Right([Forms]![frmAdd]![newID].[value],Len([Forms]![frmAdd]![newID].[value])-1),"0000000000")
AS Expr1, Forms![frmAdd]!newOther AS Expr2
FROM Customers;
I'm not sure exactly what search functionality you're looking for, but this query would pull up the record data matching that of a frmSearch with a textbox search which would have the format C### or whatever entered in:
SELECT Left([Customers].[Customer ID],1) & Replace(LTrim(Replace(Right([Customers].[Customer ID],9),'0',' ')),' ','0')
AS Expr1, Customers.[Other Field]
FROM Customers
WHERE (((Customers.[Customer ID])=Left([Forms]![frmSearch]![search].[value],1)
& Format(Right([Forms]![frmSearch]![search].[value],Len([Forms]![frmSearch]![search].[value])-1),"0000000000")));
Applying the input mask is just a way to ensure that your data is correct. If you feel the need to use one, go to the table in Design View and click on the Data Type box for the customer ID field. Find Input Mask under Field Properties -> General and click it. Then hit go to the toolbar -> Design tab -> Builder. This will walk you through it.
Input mask is not the answer for this. Input mask forces the user to input the data in a certain manner. What you need is some VBA code to run in the AfterUpdate event on a form. There's no way within the table to force the data into this pattern allowing the input method that you've requested.
There may be a more efficient way to do this, but this does the job.
http://pineboxsolutions.com/access/customeriddemo.accdb