DLookup In A Query Expression
Jun 14, 2007
Hi,
I have a DLookup expression that is working in a Control on a form :
=DLookUp("[Class] ","Class","([Forms]![Orders_Crosstab]![Indcat] = [Clind]) AND ([Forms]![Orders_Crosstab]![2005] Between [From] AND [To])")
I simplified it for test purposes as an expression in a query:
Expr1: DLookUp("[Class] ","Class","([Indcat] = [Clind])")
This gave an error - MS Access cant find the name [Indcat] in the expression.
After some R&D on the web I found a solution that works:
Expr1: DLookUp("[Class] ","Class","([Clind]=" & [Indcat])
[Indcat] and [2005] are part of the recordset where [Clind], [From] and [To] are values in the Table 'Class'
MY CHALLENGE:
I cannot find the correct way to add the extra selection criteria to the query expression (as per the form expression above) that checks the value [2005] is between the [From] and [To] values in the table. Have tried a number of combinations without success.
Any help, suggestions and/or guidance very welcome.
Regards
Tony Randell
View Replies
ADVERTISEMENT
Mar 23, 2014
I've never used DLookup before and I can't get it to work for me so far.
I have 1 table which contains products and different properties of each product, such as the weight of the product.
I have created a query which sums the weight of all products, but only for those that have a value >0 in a certain field. This all works fine.
Now I simply want to display that calculated total weight in a text box on a form. So I thought DLookup could be used for that. But I can't get it to work, maybe because I'm not putting in any criteria? In the control source of the text box
I've put the following:
=dlookup("[TotalWeight]","qryTotals")
I don't have any criteria, I just want the value from my qry expression. The textbox on my form now displays #name?
View 3 Replies
View Related
Oct 30, 2013
I have a field created in a query expression
BirthMon: Format([DOB],"mmmm")
I would like to create another field in the query using DLookup to return the value of the BrithMon.
BrithMonthID=DLookUp("MonID","tblListMons","BirthM on = Mon")
This works good if used with an unbound text box on a form, but when entered into a query expressions, an error is returned: cannot find the name 'BirthMon'
Can I used DLookUp in a Query expression to refer to another Query created field?
View 2 Replies
View Related
Jul 6, 2005
i am trying to executed q query which has a Nz function. this works fine when exceuted from access. but when i try to executed the same from Vb i get an exception
"Undefined function 'Nz' in expression"
can anyone point out why this is happening? and wts the solution?
thanks in advance
ASMS
View 5 Replies
View Related
Dec 28, 2012
I have two forms...frm1 has a text box with an expression in it and I need frm2 to display the result of the expression. I'm using the DLookup expression and it either gives me #Name? or #Error? message in the text box frm2.
=Dlookup("[loan#]","tbl_loan","[Days] =" & Forms![frm1]!Days) <that gives me #Name? message
View 7 Replies
View Related
Jun 4, 2013
1. I have a table called "CONTRACT NAMES AND NUMBERS" with a field called "REDUCED_USERS", this field is a checkbox (Yes/No in the table). This table houses all of the customers with their id numbers and basic info.
2. I have another table called "REQUESTS" which houses their orders. This also has a field called "REDUCED_USERS".
In my form "Amendment Request Tracking" I have tried to do a DLookUp in Expression Builder to check the box, per order, if the customer has reduced users in the "CONTRACT NAMES AND NUMBERS".
I have tried many variations and have just realised that this is probably because it is a yes/no field so may struggle with what to populate with (currenly nothing!).
My most recent variation of expression is (where NAD_NUMBER is the common field in both Tables and Form with relevant relationship):
=DLookUp("[REDUCED_USERS]","[CONTRACT NAMES AND NUMBERS]","[CONTRACT NAMES AND NUMBERS]![NAD_NUMBER]=[NAD_NUMBER]")
View 10 Replies
View Related
Jul 29, 2013
I have an asset database I am designing to manage our computer inventory and assets.
I am trying to get a DLookup to work with one of my forms that will auto-populate some of the fields depending on what is entered in to the ProductID field. For instance, Make, Model, Asset type...
My problem is that the string that returns contains special characters, specifically "#" and gives me the error message -
Run-time error '3075':
Syntax error in date in query expression 'productID=EN371UA#ABA'.
My expression is definitely working, it just looks like it things it has something to do with date/time which it does not. Unfortunately, most HP equipment contains a # in the Product ID number.
Here is my expression -
Private Sub ProductIDCombo_AfterUpdate()
Make = DLookup("Make", "productlist", "productID=" & [ProductIDCombo])
End Sub
Make is the field I am looking up from the ProductList table. The Product ID is the ID I'm looking up from the ProductList table to find the make. My problem is actually getting it to return the correct value of "HP or Dell or Lenovo". etc.
View 12 Replies
View Related
Feb 15, 2006
I have looked through various posts, but can't seem to find the scenario I am dealing with. I have an expense dtabase I am building. It links to a Capacity dB that contains all of our metrics, such as # of delinquent accounts, # of workable accounts, # calls made, etc. In the expense dB, I need to allocate the actual expenses from the previous month to a specific metric. I have a table that contains the expense ID, description, and the allocation metric. The allocation metric field is populated by a field list based on the table from the Capacity dB, so that the user can assign which metric is to be used in the calculation for that particular expense GLID (Unit Cost:[Expense]/[Allocation Metric]). I have tried to use the DLookup function, and it is looking in the right column based on the allocation metric, but it returns the first value, not the one based on the criteria I entered.
Metric: DLookUp([Allocation_Metric],"sqry_Actual_Total",[sqry_Actual_Total]![ActualsID]=[tbl_Expense_Download]![ActualsID])
I have seen numerous comments on the fact that DLookup is slow and that I should just join a query in my query to acheive it, but how would I join a value in one table to a field on another?
View 14 Replies
View Related
Mar 9, 2007
Hi,
I'm looking for some assistance with using the Dlookup function within a query.
I have created two tables which both have identicle fields, one is used for the importation of data and the other to append the imported data to:
Both tables fields are as follows:
Field Field Field
TypeDescriptionLength
TextstrRecType1
TextstrBranchNo2
TextstrCustNo12
TextstrTitle10
TextstrForename15
TextstrSurname25
TextstrFirstAddLine30
TextstrSecondAddLine 30
TextstrThirdAddLine30
Text strForthAddLine30
TextstrPostCode8
TextstrTelNo15
TextstrDoB7
TextstrMake10
TextstrModelNo15
TextstrAppDescription 30
TextstrProdCode6
TextstrCovPer1
TextstrSerNo20
TextstrPurDate6
TextstrPurPrice7
TextstrThirtySevenSpaces37
TextstrDPA1
TextstrExtCov1
TextstrAgentNo5
TextstrEmailAdd50
Data is imported into my table name tblImportReg containing the above fields.
I have also created another table called tblConvImpReg and what I call a lookup table called tblAppCodes.
In the tblAppcodes table I have two fields as follows:
strProdCode
strAppDescription
The strProdCode field contains a two character code which identifies the product code. i.e FF
The strAppDescription field contains a description of the product for the product code i.e. Fridge Freezer
The tblConvImpReg table has fields exactly the same as the tblImportReg table.
I want to append the data from the tblImportReg table to the tblConvImpReg table, but within that append query I want it to look up the strAppDesc field in the tblAppCodes table and according to the contents of the strAppDesc field in the tblImportReg table and populate the correct Product Code into the strProdCode field in the ImportReg table on appending to the tblConvImpReg table.
I have tried writing the following and niether method has returned what I require [both returned nothing]
ProdCode: DLookUp("[strProdCode]","tblAppCodes","[strAppDesc]= [strProdCode]")
ProdCode: DLookUp("[strProdCode]","tblAppCodes","[strProdCode]= [strAppDesc]")
Any assistance would be most appreciated
View 2 Replies
View Related
Sep 6, 2007
I am doing a Dlookup in a query based on the value of one table to look up the value of another field in a table based on two other fields in the second table.
Although my code is presently returning data it is not correct data. Any suggestions?
Test: IIf(IsNull([Attend_Prov_MMIS_Id_W039]) And Not IsNull([Attend_Prov_Lic_Num_3003_2]) And Not IsNull([Attend_Prov_Prof_Code_2165_5]),DLookUp("[Provider_Name]","tblAllProviders","tblAllProviders.[Provider_Lice_Num]='" & [Attend_Prov_Lic_Num_3003_2] & "'&" And "& " & "tblAllProviders.[Provider_Code]='" & [Attend_Prov_Prof_Code_2165_5] & "'"))
View 2 Replies
View Related
Oct 10, 2007
Hi everyone,
I am trying to set up a dlookup function for a database for the charity foundation I work for and am not sure what is the best way to go about it. I'm trying to make my own dlookup and it's coming up with an error so I'm probably doing it wrong. dlookup's are a little above my level of ability.
Anyway, I have a linked spreadsheet table that has a list of funding grants that have been received from us in the past by charities and I need to link the total of this spreadsheet to my database form for funding grant info.
The idea is that whenever a charity applies for a funding grant the dlookup will show any previous funding they have received from us.
so my dlookup is:
=DLookUp("[Total to date]","Total Funding Dispersed","[Name of Organisation] =")
There is a field called "Name of Organisation" in both my form and the spreadsheet I'm trying to get the information from, so I want the dlookup to lookup the organisation and then, if they have received previous funding, to show me the amount from the "total to date" field.
Is there an easy way to do this in a query, or can someone help me with the dlookup function? I'm lost!
View 4 Replies
View Related
Aug 12, 2015
I have a query where these are the fields:
ProductRevType
RevLag
RevFlowThru
CloseMoYr
ProjRevDate
CurrentMRC
ProjRevMRC
The ProjRevMRC field is an expression that reads:ProjRevMRC: IIf([ProjRevDate]>=DateSerial(Year(Date()),Month(Date()),1),[CurrentMRC]*[qry303a_ SFADetailMRC_ONLY]![Rev Flow Through],0)
When I run the query, it works perfectly, but when I created a crosstab query to show totals by month, I wanted the totals to be zero for the months less than the current month. Is there a way for the crosstab query to execute the expression and put zeroes for those months?
View 4 Replies
View Related
Sep 23, 2005
Can you put a Dlookup in the criteria of a query?
I have table which contains bookings
customername excursionname etc
i want to include in my query results some information relating to the excursionname for a report, so that i can use them for sorting.
how do i add a dlookup to the query to display the pickupcode for the excursionname from the table boardingpoints
i have the fieldname Expr1 etc, it might look something like this:-
=DLookUp("[pickupcode]","Excursions","[Excursionname]=query![pickuplist]![Excursionname]")
Maybe?!?
View 3 Replies
View Related
Nov 18, 2007
I have a DLookUp Expression
=DLookUp("Rate","tblLevyRates","[LevyYear]= " & [LevyYear] & " And [Species]= '" & [Species] & "'")
I use this expression in a form and it works fine.
I it as 'Rate:' in select query "qryLevyPayAll" and it works fine: -
qryLevyPayAll
SELECT tblLevyReceiptsDetail.AutoID, tblLevyReceiptsDetail.Grower, tblLevyReceiptsDetail.Species, tblLevyReceiptsDetail.LevyPaid, tblLevyReceiptsDetail.Tonnes, tblLevyReceiptsDetail.HeaderID, tblLevyReceiptsDetail.LevyYear, tblLevyReceiptsDetail.LevyDate, DLookUp("Rate","tblLevyRates","[LevyYear]= " & [LevyYear] & " And [Species]= '" & [Species] & "'") AS Rate
FROM tblLevyReceiptsDetail
WHERE (((tblLevyReceiptsDetail.LevyDate) Between [Forms]![LevyReportDialog]![DateFrom] And [Forms]![LevyReportDialog]![DateTo]));
Things are going great. BUT!!! When I base select queryB on qryLevyPayAll : -
queryB
SELECT qryLevyProcXSpp.Name, qryLevyProcXSpp.DateAdded, qryLevyPayAll.Species, qryLevyPayAll.LevyYear, qryLevyPayAll.LevyDate, qryLevyPayAll.Tonnes, qryLevyPayAll.Rate
FROM qryLevyProcXSpp LEFT JOIN qryLevyPayAll ON qryLevyProcXSpp.AutoID = qryLevyPayAll.HeaderID
GROUP BY qryLevyProcXSpp.Name, qryLevyProcXSpp.DateAdded, qryLevyPayAll.Species, qryLevyPayAll.LevyYear, qryLevyPayAll.LevyDate, qryLevyPayAll.Tonnes, qryLevyPayAll.Rate;
I get two error messages.
There is a syntatx error (missing operatro) in the DLookUp in qryLevyPayAll.
The expression is typed incorrectly or too complex to evaluate.
Now this has me completely stuck.:confused:
If the DLookUp is valid on my form and in qryLevyPayAll, why does it misbehave when I refer to the field containing it in queryB?
View 9 Replies
View Related
Feb 11, 2008
Can anyone decipher what I'm doing wrong with the following syntax:
SELECT tblEnrollment.EnrollmentID, tblEvalTypes.Abbreviation, tblOptionsBF.Abbreviation, tblEvalResults.EvalDate, tblEvalResults.FlightExaminer, DLookUp("[LastName]","tblMembers","[tblMembers].[MemberID]='" & [tblEvalResults].[FlightExaminer] & "'") AS FE, tblGrades.Abbreviation, tblEvalResults.EPE
FROM tblEvalTypes INNER JOIN (tblGrades INNER JOIN (tblOptionsBF RIGHT JOIN ((tblMembers INNER JOIN tblEnrollment ON tblMembers.MemberID = tblEnrollment.MemberID) INNER JOIN tblEvalResults ON tblEnrollment.EnrollmentID = tblEvalResults.EnrollmentID) ON tblOptionsBF.OptionsBFID = tblEvalResults.BoldfaceID) ON tblGrades.GradesID = tblEvalResults.GradeID) ON tblEvalTypes.EvalTypesID = tblEvalResults.EvalTypesID
WHERE (((tblEnrollment.EnrollmentID)=[Forms]![frmHome]![EnrollmentID]));
The problem child is:
DLookUp("[LastName]","tblMembers","[tblMembers].[MemberID]='" & [tblEvalResults].[FlightExaminer] & "'") AS FE
Thanks!
View 5 Replies
View Related
Mar 18, 2014
I need some syntax in setting 2 criterias for a DLookup query.
I've attached a sample db with 2 tables: Main & Timesheet
I need a "combo" query showing (on the same line) all Qty for Transcodes N, 1 & 2 where the Staff number and TSNum is the same.
I'm sure about the logic but the syntax is letting me down.
I can pull in 1 of the criteria E.g.:
OT1: DLookUp("Qty","ExOT1","[Staff] =" & [Staff])
But can for the life of me not script the second criteria in.
So in my result of ExCombo I'm getting Staff 11 showing 4 under OT1 while I know the result does not apply for TSNum 29832 as indicated hence the need for the 2nd criteria.
Since I have to change some of the values to text inside the query it might be best to have a look at the attached db rather than just suggesting the correct syntax .
View 3 Replies
View Related
Apr 23, 2013
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.
View 1 Replies
View Related
Jun 6, 2014
I'm designing a query. It's very simple.
I just need to compute something like:
Var: TT[YYZ for this month]-TT[YYZ for last month]
The table is called C1 and has the fields i'm interested
YYZ: Location
TT: number
mxx: date
So, i have for YYZ a list of places and for TT a list of values. MXX has the date of the record on the table.
There is one record per date, which it means, there only one record for 1/1/1991 for the YYZ=2.
NF should calculate the difference between the the record on t against t-1.
I've tried with this
Var: YYZ-DLookUp("yyz","[C1]"," "[YYZ]=[YYZ]" AND "[mxx]=DateAdd("m", "-1", "[mxx]"))
But it fails.
I upload a xls sheet with the desired field, Var ,calculated.
View 2 Replies
View Related
Mar 5, 2012
I have a query that runs just fine and takes about 1 minute to run on average. I have vba code that uses Dlookup to determine if the query returns any records. The problem is that each time it runs it has to crunch all the data, all I care about is if there is any result at all. Is there a way to get the query to stop after it finds one record to speed things up greatly?
View 2 Replies
View Related
Jul 13, 2005
Simple this one but it's something I can't seem to get working so I thought I would ask as I'm missing something obvious.
What is the correct expression to use in a query to select records with particular dates. The database contains information on quotations and each record has a follow up date field and a status field.
The query should find records where the follow up date is today and the status is "Live".
I have =NOW() in the date field and "Live" in the status field but no records are being found even when I know there are some that match the criteria.
Please advise.
Thanks
VC
View 1 Replies
View Related
Jun 7, 2006
Good Morning. Have a quick question for the gifted.
First let me say I have inside my table
Target Install, Received Date, and Type of Circuit
In the Query, I have created a column with the following statement. Due Date: [Target Install]-30 which works great to give me 30 days from the target install. The issue is that this statment is not correct for all products.
So I need to understand how to build a formula for this in the query.
If [Type of Circuit] = "Branch Network Frame" than [Target Install]-30 or
If [Type of Circuit] = "Class I" than Received Date+7
to go in the column for the query.
Thanks
View 2 Replies
View Related
Nov 16, 2007
Hello All,
Need some help with a expression Why would this equal nothing...if Ontime PU.CountOfP Performance is 32 and Late PU.CountOfP Performance is 0?
[Ontime PU.CountOfP Performance]-[Late PU.CountOfP Performance]/[Ontime PU.CountOfP Performance]
Shouldn't it be 1 or 100%......?????
Any Ideas??
View 6 Replies
View Related
Jan 15, 2008
Could someone provide me with an expression that would always return data from last week? I've been playing around with serialdate and datepart but can't quite figure it out.
Appreciate the help!
B.
View 9 Replies
View Related
Jan 7, 2014
I have been all over the internet and trying different things for hours to no solution. I have created a form (Code) which I am using to auto fill two categories in a form using dlookup. Both categories fill perfectly but I cannot get the information to transfer to a query in order to capture the information in a report.
These are the dlookups I've been using and the categories I'm attempting to capture are "Description" and "Category"
=DLookUp("Description","[Code]","[CodeID]='" & [ViolationCombo] & "'")
=DLookUp("Description","[Code]","[CodeID]='" & [ViolationCombo] & "'")
View 3 Replies
View Related
Aug 8, 2013
I am having a problem with a Dlookup query. I want to achieve the following - I have 2 different tables
Demography Table - consisting of 2 fields, City and Region
For example
City Region
NYC NAM
The other Table totalflow consists of several field, one of the is flow from.
For example
Flow from
NYC
WAS
SEA
I want to do the following. Lookup the Flow from filed in table totalflow, and compare it to City in demography Table. If City = Flow from, return the value in Region. All are text fields.
I have tried following Query, but it only returns the same value for all rows. (from SQL view)
SELECT DLookUp("[Region]","Demography Table","[City] = '" &[Flow from]& "'") AS test
FROM [Demography Table], flowsize;
View 3 Replies
View Related
May 28, 2005
I have a query with Product, Product Directorate, Date Received, Date Delivered, and Date approved fields.
Product field criteria: "NAT CONV"
Product Directorate criteria:
([forms]![frmWhatDates].[cboPD]) or ([forms]![frmWhatDates].[cboPD is null)
Date Received criteria: (Between [forms]![frmWhatDates].[txtRecvStart] And [forms]![frmWhatDates].[txtRecvEnd]) or(([forms]![frmWhatDates].[txtRecvStart] is null) or ([forms]![frmWhatDates].[txtRecvEnd] is null))
and so forth
When I closed my query, and opened it up again it looked bizarre. Because of the Is Null it added criteria multiple times.. I don't know what's going on but this makes it hard if i want to edit it in the future.
This is what it looks like:
http://img.photobucket.com/albums/v332/youmnac/qryND.jpg
Why did Access do this to my query? Is there anyway I can make this simpler and how?
What I have is a form that filters records according to what is input and it generates a report.
If that date fields are left blank.. I want it to display all the records
http://img.photobucket.com/albums/v332/youmnac/form.jpg
View 6 Replies
View Related