Reports :: DLookup With Multiple Criteria That May Change
Jan 5, 2015
I have a table named z_ResltsSampleCountMonthly. In that table I have fields SampleSize, Month and LOB.
I have a report that I need to use a Dlookup in order to pull the SampleSize by LOB into my report. However, my report has three columns that change based on the start and end dates for the report. It shows current month plus the two prior months to show a trend.
So I have each column heading update automatically based on the dates the user enters into the start and end date on the main menu form.
If they select 12/1/14 to 12/31/14 the three columns heading would update to October 2014, November 2014, and December 2014. In the table I have the data for all three months so when I use this formula it works but it's putting September 2014 data under October 2014 so I need to have multiple criteria; one being the LOB and the other being the column heading which is equal to the field Month in the table.
creating a DLookup expression for an unbound control on a report. This report displays data collected from the users from a table called tblaudit completed. This table contains (among others) three fields labeled below
Brand Form Area Changed
I also have another reference table labeled refevalareas. The fields in this table are as follows
BrandName FormName AreaName PointValue
I would like to create an unbound control on my report that "prints" the point value depending on the Brand, Form, and Area displayed for each record. Though the field names are different the data collected and displayed in each table is consistent. I haven't worked much with Lookups and the logic is challenging for me to grasp but I think I have the basic idea which is shown below..
I have a database which I have been using for over a year now which includes a Dlookup formula in a report.The dlookup references the query QRYDwgCount and looks up the number of drawings issued by a particular architect. I have been using the following formula which was previously working
The problem I have now encountered is a new job with an architect that worked on another job already in the database. Instead of bringing forward the number of drawings issued by the architect for this current job, the formula is showing the number of drawings issued for the earlier job. I therefore need to add "ContractName" = [ContractName] but I am getting either Error or an incorrect answer as the result.This is what I have written:
I am using MS Access 2010 and have an issue with one of my forms. First off, I have a table called coefficient which contains a column MIN, a column MAX, and a column COEFF.In my form, called CALC, I want to grab a number that it is in textbox [Text12] and place the related coefficient number in textbox [Text15].I placed a control source in [Text15] using =DLookup("[COEFF]","coefficient","[Text12]>[MIN] And [Text12]<[MAX]").
I can't seem to get past this expression/criteria problem.
[Actual] is my field I want to grab data from [L3-4-5] is my main table [CDATE] is a form control where the user enters a date [Quarter] is a number field and want it to equal 1 [Partname] is a text field and string it to equal 1
My current expression is:
=DLookUp("ACTUAL","L3-4-5","ID=" & [CDATE] And "[QUARTER]=1" And "[PARTNAME]='1'")
Although my other expression on another form works.In my if code statement I have
I have a form with multiple combo boxes. Once the combo boxes are populated, I need the text box to look up the value in the query based on two combo box selections.I am attempting to do a DLOOKUP, but I am obviously not doing it correctly because the result is #NAME?.
Here is what I have done: In Default Value section of the txtONE property sheet: =DLookUp([fieldTHREE],[qryMAIN],[cmbONE].[AfterUpdate] And [cmbTWO].[AfterUpdate])
I've been asked to get involved in some access development but don't seem to be get my dlookup syntax correct.I essentially want to lookup what salary band different employees are in.I have two tables:
Employee Table) has the fields: Name, Type, Salary
Salary Band Table) has the fields Employee Type, Salary Band, Lower range, Upper range..my query syntax is:
Code:
Band: DLookUp("[Salary Band]","Salary Band Table", [Salary] & " BETWEEN [Lower range] and [Upper range]" & "AND " & [Type] & " = [Employee Type]")
I can get the first criteria to work but can't get the second part to work - currently it produces an error.
In the "qryEmployeeWTax" i need to Lookup the [InitialTax] from the "qryreftbl_WTAX" based from the [ETPES] and [SalaryAfterStatutoryDeductions], so i am using this function:
I have been trying to find a solution to why I can't get a Dlookup with multiple criteria to return the value I need.
Essentially I am trying to use an Order Number to find the item number which is contained within another table. However the order number has multiple lines (suffixes) which alter the item number. Therefore I am trying to have the item number be populated by the correct 'combination' of Order Number and line ("suffix").
I have managed to use the Dlookup in the after update of each box of the form separately and they retrieve values in the table correctly:
Afterupdate of main order number:
Code:
Private Sub OrderNumbertxt_AfterUpdate() ItemNumbertxt = DLookup("item", "dbo_job", "[job] = '" & Forms![**INPUT]![OrderNumbertxt] & "'") End Sub
Afterupdate of suffix:
Code:
Private Sub SuffixTxt_AfterUpdate() ItemNumbertxt = DLookup("item", "dbo_job", "[suffix] = Forms![**INPUT]![SuffixTxt]") End Sub
However when I combine them as follows in the afterupdate of the Suffix box I receive a "Run-time error '13': Type mismatch"
Code:
Private Sub SuffixTxt_AfterUpdate() ItemNumbertxt = DLookup("item", "dbo_job", ("[suffix] = Forms![**INPUT]![SuffixTxt]") And ("[job] = '" & Forms![**INPUT]![OrderNumbertxt] & "'")) End Sub
I think the reason is something to do with some being numbers and some being a combination of text and numbers (based on the replies of other topics), but have been trying to modify these slightly and can't get it to work still.
Also the Order Number is a combination of letters and numbers (normally in the form of AB12345678), the suffix is just a number between 0-9 and the Item number it finds is a combination of numbers and letters.
I am trying to create a Dlookup in Access 2010 within a query using query wizard. I want to lookup the tax rate for an employee based on a salary range and their 'tax category' (string). Through troubleshooting I can get the criteria to work separately.
These are: DLookUp("Base","TABWT","[TABWT].[Taxclass] = '" & [FirstOfTaxGroup] & "'")
DLookUp("Base","TABWT",[grosspay] & " Between [TABWT]![Minimum] And [TABWT]![MaxBracket]")
These work and return the correct values for each column/row when I run the query.
However, when I combine the criteria (using the build wizard) as follows:
Expr1: DLookUp("Base","TABWT","[TABWT].[Taxclass] = '" & [FirstOfTaxGroup] & "'" and [grosspay] & " Between [TABWT]![Minimum] And [TABWT]![MaxBracket]")
The Dlookup will returns 0 values but will not give an error message.
I've tried quite a few variations on syntax and quotes and so on. However, it's just not working for me.
I have a list of projects and I need to display their status (Red or Green) in a text box.
My fields are [PercentComplete],[StartDate],[EndDate],[ReportDate]
There are two ways a project could have a red status.
1. [PercentComplete] < 100 AND [ReportDate] < [EndDate] OR 2. [PercentComplete]<100 AND IsNull([EndDate])
There is one way it could have a green status: [PercentComplete] = 100 AND Not IsNull([StartDate])
This is the best I could come up with for the Iif statement, but I get "invalid argument" which I suspect relates to the AND portion.
Code: Iif([PercentComplete] < 100 AND [ReportDate] < [EndDate], "Red", [PercentComplete]<100 AND IsNull([EndDate]),"Red", [PercentComplete] = 100 AND Not IsNull([StartDate]),"Green","")))
I am in the learning phase for MS Access reports. I have a datasheet which contains the employee daily activities.I need a report when either or both criteria is selected. For ex..criteria1 is Start date and End Date and criteria2 is Employee Name.Output of the report should be based on the selection of the criteria ,as I said either or both.
I am trying to put together an form to be used in an academic administration database. Ideally, I would like to create a form that will allow a user to select criteria and get a list of all students fitting that criteria. For example: Show me all a) all Economics majors with b) 30-50 Credits who c) have not taken English 101. All of this data could be compiled into one query, but I would like to create a form that will allow a user to select what data he or she would like to see. (Maybe they only want to see graduates) I hope this makes sense. And I hope someone can help point me in the right direction.
I have a report which I would like to apply conditional formatting on multiple fields. I would like the conditional formatting to be based on two types of criteria
First criteria would be contracts that start with the year 2014. I used the following expression which worked - InStr(1,[ContractNr],"2014" AND [DirectorInCharge]= "Joseph Steinbok" or "Adam Godson")
To this expression I would also like to highlight fields which contracts start with 2014 AND have a particular Director assigned to it. For this I used the following expression - And [DirectorInCharge]="Name"
On their own, both expressions are working but I want to combine them. How do I do this? I've tried the following - InStr(1,[ContractNr],"2014" AND [DirectorInCharge]= "Name") but then nothing is highlighted. I also tried InStr(1,[ContractNr],"2014") AND [DirectorInCharge]= "Name" - in this instance EVERY record was highlighted.
each boarding point has 6 different pickupcodes and pickuptimes
i am trying to create a form, which is currently displaying data from an query depending on which tour is selected from the main form.
my current dlookup is like this. =DLookUp("[pickuptime]","boardingpoints","[boardingpoint]=Forms![pickup list]![boardingpoint]")
what do i need to add to the end of this so that it also looks at the pickupcode as well as the boardingpoint to display the correct pickuptime and not just the first one it comes to?
I have an inquiry about using dlookup to retrive all fields from a table that are using the same criteria. Here's the table structure
Table1: ID (Autonumber) Number Code Grade
I have the following data: Number Code Grade 4 15 68 4 52 78 4 17 69 5 85 83 5 28 17
I am using this to retrive values for number 4 but I only get the first row DLookup("Code", "Table1", "[Number] = 4") DLookup("Grade", "Table1", "[Number] = 4")
I get only as a result 15 and 68, how can I retrive all the rows that have Number 4?
I have the following DLookup statement which if the number of bags is greater than 0 will find the previous accommodation name. How do I get it to only select the accommodation name if the CustomerID field is the same as the previous as well?
I'm back yet again with a new and intriguing set of problems. I am building a fancy report and Come to find out you cannot use SQL to return one simple number in a text box because even though you know you will write the statement to return only one answer everytime, access doesnt understand that so we can do a domain aggregate thing with DLookup. OK fine I have to do alot of them but still OK, here is my issue I can get DLookup to give me what I want if i type into each control source the criteria that I want to return.
I want to lookup a number from a recordset but there are two things that make the number unique date and strain. strain is easy to cough up in the right place because i will hard code that into the control source dlookup, the part that is killing me is the date I can get a dlookup to give me accurate results based on multiple criteria, but how can i get that to include the date for which I am running this report. I do enter the date parameter each time i open the report.
Here's what i got so far
=DLookUp("csQuantity","SpawnScheduleCulSpawn","csstrain='AC-PA'" & " AND week = #4-29-07#")
That returns the answer i want, but i have 50 of these text boxes in one report so i cant go through and write the date in each one.
how can i make the part following " AND week =" dynamic so that it runs the date that i entered as the parameter for the report?