?
Solved

Control source syntax

Posted on 2015-01-03
12
Medium Priority
?
120 Views
Last Modified: 2015-01-03
I have the following code in a control source of a field on a form but it isn't correct.  Can someone help me with the syntax?

=Nz([qryQtyDiesOrdered.SumOfQTY_ORDERED] WHERE [Part_No] = Forms!frmParts.txtPart_No -[qryQtyDiesOrderedAndReceived.SumOfQTY_ORDERED] WHERE [Part_No] = Forms!frmParts.txtPart_No  ,0)
0
Comment
Question by:SteveL13
[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
  • 6
  • 5
12 Comments
 

Author Comment

by:SteveL13
ID: 40529248
Part_No is a text field.
0
 
LVL 40

Expert Comment

by:als315
ID: 40529252
Can you explain idea? What is expected result?
If you like to get result from query, use dlookup or subform with one field only
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40529254
Test to see it criteria shows up and what is it variable type:

Step 1:
= "Show me value: " & Forms!frmParts.txtPart_No

Step 2: Find its variable type (after step 1 above shows the value correctly)
= "Show me variable type: " & VarType(Forms!frmParts.txtPart_No)

If variable type = 8 then Forms!frmParts.txtPart_No is text, it 2 then long, report back your finding.

Mike
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.

 

Author Comment

by:SteveL13
ID: 40529260
Ok.  Am trying a different approach using on current event of the form.  What is wrong with this...?

me.txtQtyOnOrder = Nz(DSum("[QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] in ('I','O','A')"),0)+Nz((DSum("[QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] ='ORD'"),0)-Nz(DSum("[QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [DATE_RECD] Is Not Null"),0))
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40529261
If vartype is 8:

= IIF(Nz(DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = '" & Forms!frmParts.txtPart_No & "'"),0),  DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = '" & Forms!frmParts.txtPart_No & "'"), (Nz(Dlookup( "SumOfQTY_ORDERED", "qryQtyDiesOrderedAndReceived", "Part_No" = '" & Forms!frmParts.txtPart_No & "'),0))
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40529268
code for If vartype is 8 is revised:

If vartype is not 8:

= IIF(Nz(DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = " & Forms!frmParts.txtPart_No ),0),  DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = " & Forms!frmParts.txtPart_No ), (Nz(Dlookup( "SumOfQTY_ORDERED", "qryQtyDiesOrderedAndReceived", "Part_No" = " & Forms!frmParts.txtPart_No ),0))
0
 

Author Comment

by:SteveL13
ID: 40529271
Getting "The expression you entered has an invalid string" with the last suggestion.
0
 
LVL 34

Accepted Solution

by:
Mike Eghtebas earned 2000 total points
ID: 40529273
Last version with vartype = 8

= IIF(Nz(DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = '" & Forms!frmParts.txtPart_No & "'" ),0),  DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = '" & Forms!frmParts.txtPart_No  & "'" ), (Nz(Dlookup( "SumOfQTY_ORDERED", "qryQtyDiesOrderedAndReceived", "Part_No" = '" & Forms!frmParts.txtPart_No & "'" ),0))
0
 

Author Comment

by:SteveL13
ID: 40529276
Now still trying to break apart the oncurrent event.  What is wrong with this code?

me.txtQtyOnOrder = Nz((DSum("[QTY_ORDERED]","tblInventory","[PART_NO] = '" & [Forms]![frmParts]![txtPART_NO] & "' AND [TRNX_TYPE] ='ORD'"),0)
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40529277
Was vartype 8? Did you have time to test it or you already know it is string?

Did you try to see if the value of

Step 1:
= "Show me value: " & Forms!frmParts.txtPart_No

shows up?
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40529279
SteveL13,

You are loosing me. Is this a new question? If so, wait to answer current one and keep your new question for another thread.

Please do step 1 and 2 above to continue.

Mike
0
 

Author Comment

by:SteveL13
ID: 40529283
This worked:  All I had to do was correct spelling of DLookup

= IIF(Nz(DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = '" & Forms!frmParts.txtPart_No & "'" ),0),  DLooup("SumOfQTY_ORDERED", "qryQtyDiesOrdered", "[Part_No] = '" & Forms!frmParts.txtPart_No  & "'" ), (Nz(Dlookup( "SumOfQTY_ORDERED", "qryQtyDiesOrderedAndReceived", "Part_No" = '" & Forms!frmParts.txtPart_No & "'" ),0))
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

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.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

752 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