473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

USING DLOOKUP TABLES

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


Nov 13 '05 #1
8 4295
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 & "#"
"NumberField = 123"

YOu might have a variable. Ex:
str = Smith
"[NameField] = '" & str & "'"

num = 123
"NumberField = " & num

Your where/filter clause needs to be adjusted.


Nov 13 '05 #2
"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.
Nov 13 '05 #3
Christine,

Look into the help file. It will show you how to use DLookup.

Jeremy

Nov 13 '05 #4

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 ***
Nov 13 '05 #5
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.SomeDataField, [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

Nov 13 '05 #6
"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.

Nov 13 '05 #7
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] = " & "'HarrisonSydney'")

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!

Nov 13 '05 #8
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] = " & "'HarrisonSydney'")

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

Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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...
1
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...
4
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...
2
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
2
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 ...
2
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...
2
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...
1
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...
7
Breezwell
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.