Solved

Format of Expression

Posted on 2004-04-13
7
359 Views
Last Modified: 2008-02-01
This is a question about how to properly create the correct expression in the expression builder to accomplish my intent but first I will give some background.

I am trying to populate the contents of a field 'SubRealTot' on a subform 'subfrm_Related_TTSDetail' based on a query 'subfrm_Related_TTSDetail' and some fields on the mainform '[Forms]![frmTTSHead_Detail_Related]![ReltdPromID]' and '[Forms]![frmTTSHead_Detail_Related]![VendorNumber]'.

I want to select the field 'RealSum' from the query entry that matches the Vendor Number and Related Promotion ID on the main form.  Below I have include the contents of the Expression builder used as the control source for the subform field 'SubRealTot', which is where I want to display the total.  It displays 0. I have never used a compound condition on a Dlookup in the expression builder and suspect that the syntax is not correct.  The expression worked when I had only the first condition
 =DLookUp("[qrySumHstDetail].[RealSum]","qrySumHstDetail","[qrySumHstDetail].[PromID]=" & [Forms]![frmTTSHead_Detail_Related]![ReltdPromID])

Of course the answer I got was incorrect because it always pulled the total for the first vendor it encountered.  I then added the the 'And' condition and now it doesn't match any entries in the query, but it should based on the contents of the respective fields on the screen.

Field 'SubRealTot' Control Source, Expression Builder contents

=DLookUp("[qrySumHstDetail].[RealSum]","qrySumHstDetail","[qrySumHstDetail].[PromID]=" & [Forms]![frmTTSHead_Detail_Related]![ReltdPromID] And "[qrySumHstDetail].[VendorNumber]=" & [Forms]![frmTTSHead_Detail_Related]![VendorNumber])

Any ideas?
0
Comment
Question by:mlcktmguy
  • 3
  • 3
7 Comments
 
LVL 10

Expert Comment

by:perkc
ID: 10814800
tRY:

=DLookUp("[qrySumHstDetail].[RealSum]","qrySumHstDetail","[qrySumHstDetail].[PromID]=" & [Forms]![frmTTSHead_Detail_Related]![ReltdPromID] & " And [qrySumHstDetail].[VendorNumber]=" & [Forms]![frmTTSHead_Detail_Related]![VendorNumber])

perkc
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10814801

you need the keyword AND as part of the text, not code

here is your updated whereclause for your DLookup

"[qrySumHstDetail].[PromID]=" & [Forms]![frmTTSHead_Detail_Related]![ReltdPromID] & " And [qrySumHstDetail].[VendorNumber]=" & [Forms]![frmTTSHead_Detail_Related]![VendorNumber])

are they both numeric fields?


0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 10815007
no, PromID and ReltdPromID are numeric, the two vendor number fields are text.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 1

Author Comment

by:mlcktmguy
ID: 10815130
Neither of the suggested formats worked.  Perhaps rockiroads has discovered the pertinent fact, that vendor number is actually a text field.  How would this change the format?
0
 
LVL 10

Accepted Solution

by:
perkc earned 100 total points
ID: 10815205
Try:

=DLookUp("[qrySumHstDetail].[RealSum]","qrySumHstDetail","[qrySumHstDetail].[PromID]=" & [Forms]![frmTTSHead_Detail_Related]![ReltdPromID] & " And [qrySumHstDetail].[VendorNumber]='" & [Forms]![frmTTSHead_Detail_Related]![VendorNumber] & "'")

perkc
0
 
LVL 10

Expert Comment

by:perkc
ID: 10815227
Text fields need a single quote before and after.  something='text'

Date fields need a number sign before and after. somedate=#date#

perkc
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 10815447
Bingo, thanks.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question