Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Getting an error on another DSUm

=Nz(DSum("Qty","tblWarehouseTransTranx","PartN = " & Chr(34) & [txtPartN] & Chr(34) & " And WarehouseID = 'AT'"),0)

Can someone help?
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image



=Nz(DSum("Qty","tblWarehouseTransTranx","PartN = " & Chr(34) & [txtPartN] & Chr(34) & " And WarehouseID = " & Chr(34) & "AT" & Chr(34) ),0)

mx
Avatar of SteveL13

ASKER

That did not work.
Most likely:

[txtPartN]

should be:

Me.[txtPartN]

  but without some context, it's hard to say what your problem is.

Jim.
Nz(DSum("Qty", "tblWarehouseTransTranx", "PartN = " & Chr(34) & Me.txtPartN & Chr(34) & " And WarehouseID = " & Chr(34) & "AT" & Chr(34)), 0)
IF PartN is numeric then

Nz(DSum("Qty", "tblWarehouseTransTranx", "PartN = " & Me.txtPartN  & " And WarehouseID = " & Chr(34) & "AT" & Chr(34)), 0)

or better yet:

Nz(DSum("[Qty]","tblWarehouseTransTranx","PartN = " & Chr$(34) & Me.[txtPartN] & Chr$(34) & " And WarehouseID = 'AT'"),0)

Jim.


 and BTW, warehouse ID is a text field right?

Jim.

@JD ... < what was the link where you asked what the Top 10 questions that are asked in EE ?>

thx.mx
So far nothing works and WarehouseID is a text field.  I'm putting this in the control source of the field so I don't need the Me.
Avatar of Norie
Norie

Have you tried using single quotes instead of double quotes?
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And what exactly is(are) the error you are getting ?
#Error
Then some table or field name is likely misspelled ...
They syntax is correct ... something else is going on.

mx
Or, using the function I provided this morning;

=Nz(DSum("Qty","tblWarehouseTransTranx","PartN = " & fnWrap([txtPartN]) & " And WarehouseID = " & fnWrap("AT")),0)


The syntax you accepted from mbizUp earlier this morning was:

= NZ(DSum("Qty", "tblForecastImports", "PartN = " & CHR(34) & [txtPartN] & CHR(34) & " And Planned = FALSE And WarehouseID = 'AM'"),0)

So modifying this should have been pretty easy.  When you said "that did not work", what did you mean, to whom were you replying.  It would be helpful, if when you respond to one of us, you indicate who you are replying to, and even include the ID # of the post, so we know who and what you are replying to.

Where is the control that you are using this as the controlsource for?  Is it in the same section of the report as the txtPartN field?




Is txtPartN (No?) a control on a form or a field?

If it's a control and this is in a form try using Me.txtPartN.Value instead of [txtPartN].
For a control source property, your syntax looks good.

Like mx said, Check the table and field names.  Also test it in the Query Builder to make sure it runs.

SUM(Qty)
FROM tblWarehouseTransTranx
WHERE PartN = 'place your actua lPN here' And WarehouseID = 'AT'

Open in new window


Also double-check your control source for an extra = sign at the beginning.  I think Access 2007 throws those in automatically - which may cause problems if you copy/paste control sources (eg from EE questions)