I have a problem using the above function in the following simplified
circumstance:
In the lookup table called "Klms Travelled" I have 3 fields, eg:
Receiver Name Receiver Suburb Klms Distance
Jones Melbourne 500
Harrison Sydney 200
Ford Brisbane 700
Jones Sydney 250
Ford Melbourne 550
In the main table named "Clients" I have the [Receiver Name] and [Receiver
Suburb] fields and based on this combination in a separate query (based on
"Clients") in a calculated field I have tried to extract the [Klms Distance]
data from the lookup table as follows:
Total Klms: DLookup("[Klms Distance]", "Klms Travelled", "[Receiver
Name]&[Receiver Suburb]")
I have also tried variations on the criteria but I either get the value of
500 for the first record in the lookup table or nothing.
Can anyone help me with a suitable criteria, or any other suggestions.
Thank you,
Christine 8 4319
Christine Henderson wrote: I have a problem using the above function in the following simplified circumstance:
In the lookup table called "Klms Travelled" I have 3 fields, eg:
Receiver Name Receiver Suburb Klms Distance Jones Melbourne 500 Harrison Sydney 200 Ford Brisbane 700 Jones Sydney 250 Ford Melbourne 550 In the main table named "Clients" I have the [Receiver Name] and [Receiver Suburb] fields and based on this combination in a separate query (based on "Clients") in a calculated field I have tried to extract the [Klms Distance] data from the lookup table as follows:
Total Klms: DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver Suburb]")
I have also tried variations on the criteria but I either get the value of 500 for the first record in the lookup table or nothing.
Can anyone help me with a suitable criteria, or any other suggestions.
Thank you, Christine
In Dlookup you pass the Column field to look up/calculate on, the table
name, and the filter clause (like a where clause w/o the word Where.
I will assume you have a query called Klms Travelled. A field in that
query is [Klms Distance]. You now need to filter. Quotes around
alphas, # around dates, nothing around numbers. Ex:
"[NameField] = 'Smith'"
"[DateField] = #" & Date & "#"
"NumberFiel d = 123"
YOu might have a variable. Ex:
str = Smith
"[NameField] = '" & str & "'"
num = 123
"NumberFiel d = " & num
Your where/filter clause needs to be adjusted.
"Christine Henderson" <ca****@idl.com .au> wrote in message
news:1127113545 .43858@idlweb.. . I have a problem using the above function in the following simplified circumstance:
In the lookup table called "Klms Travelled" I have 3 fields, eg:
Receiver Name Receiver Suburb Klms Distance Jones Melbourne 500 Harrison Sydney 200 Ford Brisbane 700 Jones Sydney 250 Ford Melbourne 550 In the main table named "Clients" I have the [Receiver Name] and [Receiver Suburb] fields and based on this combination in a separate query (based on "Clients") in a calculated field I have tried to extract the [Klms Distance] data from the lookup table as follows:
Total Klms: DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver Suburb]")
I have also tried variations on the criteria but I either get the value of 500 for the first record in the lookup table or nothing.
Can anyone help me with a suitable criteria, or any other suggestions.
Thank you, Christine
For a fixed example, you would write (note the sets of quotes surrounding
the values):
DLOOKUP("[Klms Distance]",
"[Klms Travelled]",
"[Receiver Name]=""Ford"" AND [Receiver Suburb]=""Melbourne""" )
In your case, instead of the values "Ford" and "Melbourne" , you would get
the values from your main form.
Christine,
Look into the help file. It will show you how to use DLookup.
Jeremy
Dear Brian
Thanks for your suggestion regarding the cominbation of the two fields,
ie [Receiver Name]= "Ford" AND [Receiver Suburb]= "Melbourne"
My problem is that I do not want to specify a record such as "Ford" and
"Melbourne" I need to lookup all records from my main table query and
have the klms travelled returned from the lookup table.
I understand the use of quotes etc and have tried the expression above
without specifying specific records however I only get the klms for the
first record in the lookup table.
Is it possible to specify just the field names as the criteria without
needing = a record.
Thanks for any help available on this problem.
Regards
Christine
*** Sent via Developersdex http://www.developersdex.com ***
Christine Henderson wrote: Dear Brian
Thanks for your suggestion regarding the cominbation of the two fields, ie [Receiver Name]= "Ford" AND [Receiver Suburb]= "Melbourne"
My problem is that I do not want to specify a record such as "Ford" and "Melbourne" I need to lookup all records from my main table query and have the klms travelled returned from the lookup table.
I understand the use of quotes etc and have tried the expression above without specifying specific records however I only get the klms for the first record in the lookup table.
Is it possible to specify just the field names as the criteria without needing = a record.
Thanks for any help available on this problem.
Regards Christine
*** Sent via Developersdex http://www.developersdex.com ***
I'm taking a shot in the dark. The SQL of your query might look
something like:
SELECT Main.[Receiver Name], Main.[Receiver Suburb],
Main.SomeDataFi eld, [Klms Travelled].[Klms Distance] FROM Main INNER
JOIN [Klms Travelled] ON (Main.[Receiver Suburb] = [Klms
Travelled].[Receiver Suburb]) AND (Main.[Receiver Name] = [Klms
Travelled].[Receiver Name]);
Basically, you need to select both tables into the query editor and
link both the [Receiver Name] and [Receiver Suburb] fields. You can
even get fancy by changing the join types by clicking on the lines
joining the two tables. You can show any data from Main along with the
[Klms Distance] for that combination of [Receiver Name] and [Receiver
Suburb].
The way I would actually do it is to use a subquery to gather just the
[Klms Distance] appropriate for that record instead of using the query
you have. Perhaps a little more information about how the [Klms
Distance] is obtained would allow someone to craft an appropriate
subquery.
James A. Fortune
"Christine Henderson" <ca****@idl.com .au> wrote in message
news:WV******** *********@news. uswest.net... Dear Brian
Thanks for your suggestion regarding the cominbation of the two fields, ie [Receiver Name]= "Ford" AND [Receiver Suburb]= "Melbourne"
My problem is that I do not want to specify a record such as "Ford" and "Melbourne" I need to lookup all records from my main table query and have the klms travelled returned from the lookup table.
I understand the use of quotes etc and have tried the expression above without specifying specific records however I only get the klms for the first record in the lookup table.
Is it possible to specify just the field names as the criteria without needing = a record.
Thanks for any help available on this problem.
Regards Christine
Hi Christine
Perhaps the suggestion from James will be of some help, but I just wanted to
add that DLOOKUPs are supposed to be an easy way to look up a single record
in a table. E.g. if the name is Ford and the suburb is Melbourne, then how
many kilometers is this?
What I now guess you are doing is a query which should involve two tables.
So just create a new query in design view and add the main table, then the
lookup table.
Drag the field [Clients].[Receiver Name] onto [Klms Travelled].[Receiver
Name] and then [Clients].[Receiver Suburb] onto [Klms Travelled].[Receiver
Suburb]. Then select the fields you want to display and run the query. You
will notice that if the distance is not found in the lookup table, then the
record will not be displayed at all. To remedy this, return to the design
view, right-click each joining line and make sure you select "display all
records from Clients...". When you re-run the query, you should find that
all client records are displayed and where possible a distance is also
included.
Let us know if this sorts it out.
Christine:
You're wanting to use the DLookup to get a specific Klms Traveled, but
you aren't specifying WHICH record you want looked up. That's why
you're only getting the first record's Klms Traveled. The last
parameter of the DLookup is a Where clause without the word Where. In
the example you have your Where clause is really saying "Where
[Receiver Name]&[Receiver Suburb]". The problem is, you don't have
what [Receiver Name]&[Receiver Suburb] should be equal to. You need to
feed some criteria to your clause so that it says [Receiver
Name]&[Receiver Suburb] = 'Something'. You need to pass something to
your DLookup so it makes a complete criteria specification. For
instance, if you wanted to find the Klms Traveled for Harrison in
Sydney, your DLookup would look like this:
DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver
Suburb] = " & "'HarrisonSydne y'")
You can replace the 'HarrisonSydney ' with a field from a form, or if
this is for a query, you can use the field names from your query.
For a form field, do this:
DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver
Suburb]='" & Forms!FormName! FieldName & "'")
If you're trying to do this in a query, do this:
DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver
Suburb]='" & [Receiver Name] & [Receiver Suburb] & "'")
Hope that helps!
Jana wrote: Christine:
You're wanting to use the DLookup to get a specific Klms Traveled, but you aren't specifying WHICH record you want looked up. That's why you're only getting the first record's Klms Traveled. The last parameter of the DLookup is a Where clause without the word Where. In the example you have your Where clause is really saying "Where [Receiver Name]&[Receiver Suburb]". The problem is, you don't have what [Receiver Name]&[Receiver Suburb] should be equal to. You need to feed some criteria to your clause so that it says [Receiver Name]&[Receiver Suburb] = 'Something'. You need to pass something to your DLookup so it makes a complete criteria specification. For instance, if you wanted to find the Klms Traveled for Harrison in Sydney, your DLookup would look like this:
DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver Suburb] = " & "'HarrisonSydne y'")
You can replace the 'HarrisonSydney ' with a field from a form, or if this is for a query, you can use the field names from your query.
For a form field, do this: DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver Suburb]='" & Forms!FormName! FieldName & "'")
If you're trying to do this in a query, do this: DLookup("[Klms Distance]", "Klms Travelled", "[Receiver Name]&[Receiver Suburb]='" & [Receiver Name] & [Receiver Suburb] & "'")
Hope that helps!
In addition to what I wrote it would be good to add that DLookup is, in
effect, a poor man's equivalent to a subquery. So think in terms of a
normal query containing a DLookup to get a particular piece of
information that relates to the current record in the query. Perhaps
show the fields of interest in Main.
James A. Fortune This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Hargrove |
last post by:
I am building a database to manage test samples in an environmental
laboratory. I am learning Access as I go and don't know much about
the programming aspects. I hope to make the application user-friendly
for the sample login people by populating form controls. Using the
DLookup function, I am able to populate a form control in one record
using table data. I want to be able to populate multiple records of a
subform control (test...
|
by: annie |
last post by:
Hi all,
I have recently ported my Access 2000 app to SQL Server, keeping the
Access client as the front end using linked tables.
I am also using triggers on my SQL tables to trap orphan records and
validate added data.
My question is..
|
by: basstwo |
last post by:
I have a field with a serial number in it. I want to use Mid to
extract the 4th and 5th characters, use them to lookup a value on a
small lookup table, and use the info from that table to fill in the
value for my lens field. I tried doing this:
=DLookUp(!,,Mid(!,4,2)=!)
Where LensLookup is my lookup table, LensName is the value I want to
have appear
|
by: c.kurutz |
last post by:
Hello everyone. I have a problem with looking up pricing. Here is
what I have so far:
TABLES
tblItems:
itemid
itemdescription
itemunit (each, roll, square foot)
location1price
|
by: hr833 |
last post by:
i'm having trouble with Dlookup.I'm trying to insert a Dlookup statement in a update query, so that the user need not upate each record manually.
Supplier Catergory
sSupplierName
sCatergory
Transaction
tSupplierName
tAmount
tCatergory
| |
by: RoadrunnerII |
last post by:
Hi All
I am new to this forum and still learning MS Access. Hoping this is the right place to ask If not please let me know!
Looking for some help with the SQL statements in Access 2003 with the tables backended into MS SQL Server 2005
The queries work fine but cause the forms to be quite slow if I leave them as is.
If I convert the Queries into Passthrough queries as suggested by a DBA I cannot get the Dlookup below to work
The error I get...
|
by: Denise |
last post by:
Front end is Access 2002, back end is linked Oracle tables.
My users need to describe things in feet and inches and want to use
the standard ' and " abbrevations.
On a testing form I go to a record with double or single quotes in the
location description and click a button to see if Access can tell me
the ID number and find its way back to the original record.
When the text contains double quotes the FindFirst works but the
Dloookup...
|
by: Constantine AI |
last post by:
Hi i am trying to get User input if data does not exist within a DLOOKUP table. I have gotten it to work for one record but not multiple, i have tried to incorporate my code into a loop procedure but i have failed. Could anyone give me any advice?
Dim db As Database
Dim rst As Recordset
Dim rst2 As Recordset
Dim strSQL As String
Dim Widthval As Integer
Dim Depthval As Integer
Dim Heightval As Integer
Dim...
|
by: Breezwell |
last post by:
This is probably a simple question for someone out there.
I understand that the DLookup function takes has the following syntax:
DLookup(expression,domain,)
From what I have read, domain can be a table or query.
I have no problem getting the function to work when I use the actual name of a table for the domain. My question is, can I utilize a combobox that lists the names of my tables and pass the value of the selected table from...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |