473,425 Members | 1,888 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,425 software developers and data experts.

DLookUp Problem

WWH

New to Access and have what should be a simple problem.

Have two tables...

1. first table has description of herbs and Chapter+Section number (ie
2.3 - decimal)
2. second table has same Chapter+Section number + column for English
description (text)

Both Chapter+Section are stored in decimal format (eg. 10.2)

Sooo.... trying to generate a report where it prints the Chap+Sect
number
and then follows it with the English text description... ie 2.1 Heat
Clearing Herbs

I use the following:

=DLookUp("[Herb_Category]","[tbl_HerbCategory]","[Section_number] = " &
1.1)

This correctly prints English description for Chap+Sect 1.1.

However... when I replace the fixed constant 1.1 with the control
field
SECTION (or [SECTION]) from the first table (because I want it to
cycle through each Chap.Sect)... I get #ERROR on the report.

What am I doing wrong ? Thanks so much for help.

Dec 9 '05 #1
6 1790
Hi,

It appears that you are referencing an open form? Try this:

=DLookUp("[Herb_Category]","[tbl_HerbCategory]","[Section_number] =" &
"'" & forms!formName!Control & "'")

Hope this helps

Anton

Dec 9 '05 #2

Hi Anton

Thanks for your reply. Sorry I was not
clear.... am trying to display a report
and having it display each Chapter/section.

Thus... in the detail part of the report
it is referencing the control field SECTION
which is to print (for example 2.1), then
follow it with the English text equivalent
which works fine when I use a static value
(eg 1.1), but comes up with #ERROR when I
replace 1.1 with SECTION in the actual
report (no form involved, nor is there a
prompt for the specific Chapter/Section
to print). Although that might be useful
too at a later point !

Soooo... any thoughts on the syntax
when just used within the report ? Thanks !
*** Sent via Developersdex http://www.developersdex.com ***
Dec 9 '05 #3
Morning, just a few questions then the clarify. Is the report you are
using bound to a table/query or are you using dlookup to build the
datasource at runtime? How are the chapter and sections related; can
you give me some information on the structure of the datasource you are
using? I don't quite understand how 2.1 and 1.1 can be used as the
basis for a reference. Let me know and we can take it from there.
Cheers Anton

Dec 9 '05 #4

Hi Anton

Sorry - new to this... I will try to be more
clear.

This is being done in a report - not a query
or a form. I simply want a report to print
out the complete list of herb names, section
by section.

Should look like this:

Section 2.1 Clear heat herbs <<< section header

2.1 HerbName1 << generated by detail
2.1 HerbName2 << section in the report

Section 2.2 Clear damp herbs <<< section header

2.2 HerbName3
2.2 HerbName4
2.2 HerbName5

etc

Initially I had problems with syntax and getting
this to work... soooo... I broke it down and
just used a constant value (1.1 or 2.1 - same
difference) in the lookup.

Thus in the report (section header) we find
the following:

Section [Section]
=DLookUp("[Herb_Category]","[tbl_HerbCategory]","[Section_number] = " &
2.1)

This correctly produces:

Section 2.1 Clear heat herbs

But since I want this to print correct section headers
for ALL herbs in the list... I made one
change in the DLookUp:

=DLookUp("[Herb_Category]","[tbl_HerbCategory]","[Section_number] = " &
[Section])

Replacing the 2.1 constant with [Section]

The section# prints/indexes correctly... but
the lookup which should print the English text
instead produces #ERROR.

I don't know why, and I don't know how to
debug further or fix it. I am stuck.

And yes, the report is bound to table: Herb_table.
The English text descriptions are found in
table: tbl_HerbCategory

Thank you so much for your help - I really
appreciate it.

ps. eventually I would like to do a prompt
and just print a specific section of
herbs (likr your example - I think), but
for now.. was just trying to generate
a "simple" complete report !
*** Sent via Developersdex http://www.developersdex.com ***
Dec 9 '05 #5
W. W. Hutton <ww******@aol.com> wrote in
news:Xs***************@news.uswest.net:

Hi Anton

This is being done in a report - not a query
or a form. I simply want a report to print
out the complete list of herb names, section
by section.

Initially I had problems with syntax and getting
this to work... soooo... I broke it down and
just used a constant value (1.1 or 2.1 - same
difference) in the lookup.

Thus in the report (section header) we find
the following:

Section [Section]
=DLookUp ("[Herb_Category]","[tbl_HerbCategory]","[Section_numbe r] = " & 2.1)

This correctly produces:

Section 2.1 Clear heat herbs

But since I want this to print correct section headers
for ALL herbs in the list... I made one
change in the DLookUp:

=DLookUp ("[Herb_Category]","[tbl_HerbCategory]","[Section_numbe r] = " & [Section])

Replacing the 2.1 constant with [Section]

The section# prints/indexes correctly... but
the lookup which should print the English text
instead produces #ERROR.

A few things to check: 1) although it looks like a number,
{section] may actually be a text type field. You may need to
wrap a cdbl() or val() function to get Access to see it as a
number. 2.) the name of the textbox on your report that
contains [section] may be something else, like text13. If it is,
see if using the name of the textbox. 3) lose the square
brackets. they may be confusing Access.

--
Bob Quintal

PA is y I've altered my email address.
Dec 10 '05 #6
Ok...your best (and at this stage) most simplest way of producing this
report will be to create a query with the herb_table and
herb_Categegory linked by the section numbers. As I am not entirely
sure on the names that you have used for your fields you will need to
think about this a little bit (it is however quite 'logical'). Build a
new query and move to the SQL view from the view menu and paste in the
following and then save and run your query to see if you get the
results that you desire:

SELECT Herb_table.*, tbl_HerbCategory.* FROM tbl_HerbCategory INNER
JOIN Herb_table ON tbl_HerbCategory.Herb_CategoryID =
Herb_table.Herb_ID;

After you have built the query build a new report based on it either
using the report wizard or drop the appropriate fields into the
sections as required. If you do it manually remember to group your data
on the herb_ID eg: 1.1 etc. Once again I hope this helps.

Anton

Dec 10 '05 #7

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

Similar topics

2
by: Ronny Sigo | last post by:
Hello all, I already put the same question, only now I have more to tell ... Although I used this code before in the same routine (only the fieldname of the table differs) ___ at this point in the...
0
by: Tony Williams | last post by:
I have posted a number of posts in the Access newsgroups concerning my problem with DLookup. I have had a number of the experts with helpful suggestions but I still can't get it to work! This is...
2
by: ctyrrell | last post by:
I have read with interest the many discussions of the 3048 Error: Cannot open any more databases. I understand how the number of open Table ID's causes the problem. My question has to do with the...
8
by: Christine Henderson | last post by:
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 ...
6
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
2
by: chris.thompson13 | last post by:
I am having a problem setting the criteria part of the DLookup method correctly and am consequently getting an error message. I have a database of staff duties, part of which is a query (qryDaily)...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
2
by: boyleyc | last post by:
Hi all the following code works perfectly well. Basically it populates a series of check boxes on my form, depending on whether dlookup finds an associated record. The problem i have is that...
15
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.