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

Another Dlookup problem

Does DLookup work in an expression in a query? I have this expression
[txtDomfacsoleqtr]-(DLookUp("[txtDomfacsoleqtr]","tblmaintabs","[txtMonthlab
el]= [txtqtr1]"))
Which works fine as a calculated control on a form but when I try to use it
in a query as an expression I don't get any result. I want to use the Sum of
the result in a query on which I will base a report.

TIA
Tony
Nov 13 '05 #1
7 2222
You can't have an "=" in your criteria, as your criteria is only one side of
the equation. If [txtqtr1] is the field/query column, that you wish to
filter on, then use:

[txtDomfacsoleqtr]-DLookUp("[txtDomfacsoleqtr]","tblmaintabs","[txtMonthlabel]")

as the criteria.
-Ed
"Tony Williams" <tw@tcpinvalid.com> wrote in message
news:cu**********@titan.btinternet.com...
Does DLookup work in an expression in a query? I have this expression
[txtDomfacsoleqtr]-(DLookUp("[txtDomfacsoleqtr]","tblmaintabs","[txtMonthlab
el]= [txtqtr1]"))
Which works fine as a calculated control on a form but when I try to use
it
in a query as an expression I don't get any result. I want to use the Sum
of
the result in a query on which I will base a report.

TIA
Tony

Nov 13 '05 #2

Tony Williams wrote:
Does DLookup work in an expression in a query? I have this expression
[txtDomfacsoleqtr]-(DLookUp("[txtDomfacsoleqtr]","tblmaintabs","[txtMonthlab el]= [txtqtr1]"))
Which works fine as a calculated control on a form but when I try to use it in a query as an expression I don't get any result. I want to use the Sum of the result in a query on which I will base a report.

TIA
Tony


I would use a calculated control in the query to hold the result of
your DLookup and then use that as part of your sum. You could use
something like this in the query grid: Result:DLookup(Whatever) then
SumForReport: [txtWhatever]-[Result]

Nov 13 '05 #3
Tony,

I don't know if it would work, but far easier, and more standard, is to
just include the related table, and the field from that table. That's
the great thing about queries, you can include more than one table.

Jeremy

Nov 13 '05 #4
Thanks Ed. What I'm trying to do is to get the expression in the query to
calculate the difference between the value of txtDomfacsoleqtr in the
present quarter and the value in the previous quarter, hence the reason why
I'm using the DLookup to determine the value in the previous quarter,
txtMonthlabel is the current quarter and txtqtr1 is the previous quarter
which is calculated in another query as DateAdd("m",-3,[txtmonthlabel]) I've
joined the two queries together
I'm actually trying to create a report from a query
I've modified my expression and this is what it now looks like
[Sum of txtDomfactotqtr]-(DLookUp("[Sum of
txtDomfactotqtr]","qryFDASalesv3v2","[txtmonthlabel] = #" & [txtqtr1] &
"#"))
The report is based on a query qryFDASalesv3v2
The controls Sum of txtDomfactotqtr and txtqtr1 are in the query
The control Sum of txtDomfactotqtr is an expression in the query which is
Sum([txtDomfacsoleqtr]+[txtDomfacpartqtr]) which are fields in my table
The control txtqtr1 is an expression in the query which is
DateAdd("m",-3,[txtmonthlabel])
The control txtmonthlabel is a control based on a field in the table on
which the query is based.

That any help?
Tony

"Ed Robichaud" <ed*********@wdn.com> wrote in message
news:W6*******************@monger.newsread.com...
You can't have an "=" in your criteria, as your criteria is only one side of the equation. If [txtqtr1] is the field/query column, that you wish to
filter on, then use:

[txtDomfacsoleqtr]-DLookUp("[txtDomfacsoleqtr]","tblmaintabs","[txtMonthlabe
l]")
as the criteria.
-Ed
"Tony Williams" <tw@tcpinvalid.com> wrote in message
news:cu**********@titan.btinternet.com...
Does DLookup work in an expression in a query? I have this expression
[txtDomfacsoleqtr]-(DLookUp("[txtDomfacsoleqtr]","tblmaintabs","[txtMonthlab el]= [txtqtr1]"))
Which works fine as a calculated control on a form but when I try to use
it
in a query as an expression I don't get any result. I want to use the Sum of
the result in a query on which I will base a report.

TIA
Tony


Nov 13 '05 #5
Thanks Jeremy I've done something like that would you have a look at my
reply to Ed?
Thanks for your input
Tony
<al*****@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Tony,

I don't know if it would work, but far easier, and more standard, is to
just include the related table, and the field from that table. That's
the great thing about queries, you can include more than one table.

Jeremy

Nov 13 '05 #6
Tony,

I've never done anything like that (comparing one record to another in
a single query). But I've seen people write about it here. I think
there may be an article on it at The Access Web
(http://www.mvps.org/access/), though I'm not sure. I would have a look
there, and if you don't find anything, try searching google's archives
for things like "compare one record to another" and various
modifications of that.

Sorry I can't help more.

Jeremy Wallace

Nov 13 '05 #7
Thanks Jeremy I'll look at that site.
Regards
Tony
<al*****@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Tony,

I've never done anything like that (comparing one record to another in
a single query). But I've seen people write about it here. I think
there may be an article on it at The Access Web
(http://www.mvps.org/access/), though I'm not sure. I would have a look
there, and if you don't find anything, try searching google's archives
for things like "compare one record to another" and various
modifications of that.

Sorry I can't help more.

Jeremy Wallace

Nov 13 '05 #8

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

Similar topics

1
by: qwweeeit | last post by:
Another math problem easier to solve by hand, but, IMHO, difficult to program in a concise way like the solution of Bill Mill (linalg_brute.py) to the problem of engsol. I appreciated very much...
7
by: Gustaf Liljegren | last post by:
I continued on the example shown earlier today: http://gusgus.cn/test/index.html Now I get some unwanted space in Firefox (the red space just below the first image) which doesn't appear in...
4
by: David B | last post by:
I have a Public function which creates a back up copy of a back end. It works fine with the source path and source file as C:\folder\etc. I thought I would try to store the paths in a table so...
7
by: Tony Williams | last post by:
I'm trying to calculate for a report the previous year to date value of a control I'm using this: =DLookUp("","qryFDASalesV2","Year()=Year()") The report is based on a query "qryFDASalesV2" and...
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: g.ormesher | last post by:
Hi, my primary key is a field called "ind" 'Code Dim varUP as Varient Dim varIND as Interger varIND = Me.ind ' this sets varIND to the index value
3
by: mmorgan1240 | last post by:
I have a form that I am trying to update. I would like to have a field populated by another table (State_laws) based on the value of another field on the form. I have a field called "state". When...
11
by: vkong85 | last post by:
I'm creating a database for work and i've run into a snag. Currently i'm using to nested dlookup statements and they are searching for certain criteria in order to find the correct value the...
2
by: tomash | last post by:
Hi! I ve got two tables in Access 2007. I want to update a field of DataTable from another table, DataSumTable when two of their fields equals. ( the fields : Name and Period) I tried this...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.