?
Solved

Format of Expression

Posted on 2004-04-13
7
Medium Priority
?
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

718 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