DLookup In Query

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 Replies


ADVERTISEMENT

DLookup In A Query

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

DLOOKUP In A Query

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

Dlookup Or Query?

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

Can You Use A DLookup In The Criteria Of A Query

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

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 2 Replies View Related

DLookUp Problem In Query

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

DLookUp In Query Issues

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

Forms :: DLookup Without Criteria - Getting Value From Query Expression

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

Queries :: Setting 2 Criteria For A DLookup Query

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

Queries :: Multiple Criteria In DLookup Query

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

Queries :: Compute Field With DLookUp In Query?

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

DLookup To Determine If Query Returns Any Records

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

Queries :: Reporting Results Of DLookup In Query For Reports

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

Queries :: DLookup And Variables - Query Returning Same Value For All Rows

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

Queries :: DLookup To Return Value Of Field In Query Expression

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

Queries :: DLookup - Combine Multiple Criteria Syntax In Query

Apr 17, 2013

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.

View 3 Replies View Related

Forms :: DLookup - Using Two Fields (number And Drop Down Text) To Query Table For Data

May 29, 2015

DLookup function. (this is for a stamp collection database).

On my form ("InventoryInput") I have a text box called "Catalog" for a numeric entry and a text combo box for selecting a "Country" in drop down list.

I want to query a table called "CatNameList" to get the "StampName" of the item (based on the entries of Catalog and Country) and populate that name in the text box. The fields in this table are called "StampName", "CatNumb" & "CName" respectively.

I have successfully placed the following expression in the control source of that textbox and able to populate the StampName I need based solely on the catalog number alone.

That express is :
=DLookUp("StampName", "CatNameList", "CatNumb = Form![Catalog]")

So it will populate the "StampName" data to match the "Catalog" number entry just fine.

However, I need to add a second layer to incorporate the Country.

Example : There is a catalog "1" for "USA", and a catalog "1" for "Canada" but both have different "StampName".

I have been attempting to get that second piece added with no success. Here is the expression I have been trying to get to work :

=DLookUp("StampName", "CatNameList", "[CatNumb] = " & [Catalog] & " And CName = '" & [Country] & "'")

Right now, the text box is just blank with the above expression. I thought it may be because there was no match found, but I have triple checked to ensure I have the spelling correct on the country name in both places.

Basically, I just need the dlookup to take the "catalog" and "country" off the form and match it to the "CatNameList" table fields of "CatNumb" and "CName" to give me "StampName" field back on the form.

View 4 Replies View Related

DLookup - Using Two Form Fields (Number And Drop Down Text) To Query Table For Data

May 29, 2015

Having problems getting dlookup to work in the control source field of a text box.

My form has fields : Catalog # (numeric value) and Country (drop down text selection).

I would like to query a table CatNameList for a name (text) if the catalog # and country find a match on the table.
My field names on the CatNameList table are : Name, Number (to validate against the Catalog # entered on the form) and CName (to validate against the Country drop down on the form).

I am successfully able to populate the name from the CatNameList table on my form using lookup of the catalog # using this :

=DLookUp("Name","CatNameList","Number = Form![Catalog #]")

However, I will eventually have several catalog numbers that will be identical in the table CatNameList, thus why the country is important as the second criteria to be added into the dlookup.

I have tried for a few hours unsuccessfully to add the second portion to my dlookup.

This is what I have currently (not working) that I have been playing with, I'm sure I'm missing a quote mark, & or something simple.

=DLookUp("Name", "CatNameList", "Number = Form![Catalog #] And CName = ‘”& Form![Country] & ”’”)

View 14 Replies View Related

DLookup Not Right

May 2, 2005

Can anyone see where I've gone wrong. The purpose should be if the value in the query is 0 or less (a minus amount) and the order number and part number matches the order number and part number on the form then a warning should appear. It's not picking up the record for flagging when it should:

If (DLookup("OutstandingQty", "qryremaininginvoiceamount", "OutstandingQty <= 0" & " And [OrdNo] = " _
& Me.[OrdNo] & " And [InvPtID] = " & Me.InvPtID)) Then

View 6 Replies View Related

Dlookup's

May 19, 2006

Hi,

I am pretty new to Ms Access.

I have a table which has a list of trades (Builder, Carpenter, Painter etc) going down the side and going across the top I have the number of employees (1Emp, 2Emp, 3Emp). The values in the table show the charge for that number of employees for that trade.

I have a form which has three combobox's that show the Number of Manual Employees, Number of Clerical Employees and the number of working directors and a combo box that shows the trade. What I want to happen is when the user clicks a command button on the form the charge for the total number of employees for that trade is shown in a txt box.

I have the following code attached to my button:

Private Sub GetValue_Click ()
Dim TotalEmployees As Integer

TotalEmployees = [NoManual] + [NoClerical] + [NoWorkingDir]

Value = Dlookup(TotalEmployees & "Emp", "ValueTable", "[Business] = Forms![Form1]![Business]")

End Sub.
When I type "[3Emp]" in the Dlookup it will work fine and finds the charge for that trade. But when I pass it the Result from the addition and concatenate it with "Emp" it doesn't seem to work.

I originally thought it was because I declared the TotalEmployees as an Integer by I also tried declaring it as a string - to no avail.
I just can not figure out why it will not look up the TotalEmployees.

I would much appreciate any help on this on any suggest as to how I can get the values from my table.

Charlene

View 1 Replies View Related

How Do I Use DLookup???

Jul 7, 2006

I am using Dlookup to look up LastName, I have

AssignBy = DLookup("[LastName]", Employees, "POC =" & Me.Combo22)

I am getting an ERROR ""You entered an invalid argument in a domain aggregate function"

I need AssignBy = LastName from Employees Table where POC=what is selected in Form for Combo22.

ex. POC=3 go to Employees Table find POC that equals 3 and get the LastName.

Please Help!!

Jessie

View 4 Replies View Related

DLookup

Mar 26, 2007

Please help prevent my laptop from being smashed against a wall numerous times and then being thrown out the window, after all, the wall is mostly innocent in this situation.


I have read post upon post and other dim references to DLookup in the Access Help file, etc. I am generally a bright guy (although inexperienced in DataBases, VBA and some forms of lovemaking) but I have not been able to figure out the DLookup function. Could you please give me a VERY simple explination of how to use this function and it's expressions?

If it will help, we can use the following senario...

Table_Special_Needs
Special_Need_ID
Special_Need (Data Includes: Initiatives, High Ropes, etc.)
Standard_Price

Table_Event
Event_ID
Initiatives
High_Ropes
Extra_Linens

I would like to be able to add a price field for each item in the Event table and have the table lookup the price from the Special Needs table.

Many thanks for any help you can give.

t
:confused:

View 2 Replies View Related

Dlookup ?

Oct 19, 2007

I would like to know if i am doing an Inventory in an Invoice Program and i want the [quantity] from a subform on the Orders Form to be deleted automatically from a Products Table , Would the Dlookup Function Help and if yes how would i implement it ?

Regards Dups

View 2 Replies View Related

Dlookup

Feb 18, 2008

Dear all,

Firstly, thank you all for allowing me into your group!

Secondly however, PLEASE HELP!

I've created a database for storing students details and exam records for my university department, and everthing is fine except for one final problem: In order to allow final grades to be calculated all student marks have to be stored numerically, but each number corresponds to a code: eg N=0, G2=1, G1=2 .... A1=22

I'm trying to get the student marks report to display not just the numeric code, but also the final code eg, C2. To do so I've been trying to use DLookup as follows:

Expr1: =DLookUp("[Grade Code]","Lookup Table","[Score]= Forms![Total Grade]")

where "Grade Code" is a field in the Lookup Table (ie, it lists the A1, A2), "Lookup Table" is a table listing all the numbers and their corresponding codes, "Score" is the numeric score in the "Lookup Table" table, and "Total Grade" is a calculated (Numeric) field in the open report (though created in an accompanying query). I just can't get it to work however!! When I run the report, the column is just blank, and nothing I do seems to be able to get the corresponding code (Eg, B1, B2) to appear on the report!

Please help me if you can, I'm not kidding when I say my job is on the line with getting this database to work! Once I've got this sorted, all I need to do is find a way of letting the secretaries input the alphanumeric code, but the database automatically stores that as a number. I figured however, that sorting the first problem will go some way to finding out how to sort the 2nd one!

Thank you all just for being out there!

View 3 Replies View Related

Dlookup

Oct 12, 2007

Do the Access functions dlookup, etc. cause performance issues when using remote SQL servers where the data is held?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved