Solved

Control source syntax

Posted on 2015-01-03
12
110 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
  • 6
  • 5
12 Comments
 

Author Comment

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

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 33

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
 

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 33

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 33

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

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

Accepted Solution

by:
Mike Eghtebas earned 500 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 33

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 33

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

758 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now