Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Two D Statemnets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DS - 08 Jun 2007 15:34 GMT
How can I combine these two statements into one?
Thanks
DS

=Nz(DSum("-(CDFinalPrice*CDDiscountPercent) *
CDQuantity","tblCheckDetails","[CDCheckID]= " &
[Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID] =31"),0)

=Nz(DSum("-CDDiscountAmount*CDQuantity","tblCheckDetails","[CDCheckID]=
" & [Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID] =31"),0)
DS - 08 Jun 2007 15:57 GMT
> How can I combine these two statements into one?
> Thanks
[quoted text clipped - 6 lines]
> =Nz(DSum("-CDDiscountAmount*CDQuantity","tblCheckDetails","[CDCheckID]=
> " & [Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID] =31"),0)
I came up with this but I'm getting the #Name error.

=DSum(If("CDDiscountDP"=1,("CDDiscountAmount*CDQuantity"),(("CDFinalPrice*CDQuantity")*"CDDiscountPercent")),
"tblChecks","CDCheckID = " & [Forms]![frmCheckPreview]![TxtSalesID] & "
AND [CDItemID] > 42")
DS - 08 Jun 2007 16:27 GMT
>> How can I combine these two statements into one?
>> Thanks
[quoted text clipped - 13 lines]
> "tblChecks","CDCheckID = " & [Forms]![frmCheckPreview]![TxtSalesID] & "
> AND [CDItemID] > 42")
I also did this, it works but it doesn't seem effecient.

=Nz(DSum("CDDiscountAmount * CDQuantity","tblCheckDetails","[CDCheckID]=
" & [Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID]
=31"),0)+Nz(DSum("-(CDFinalPrice*CDDiscountPercent) *
CDQuantity","tblCheckDetails","[CDCheckID]= " &
[Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID] =31"),0)
BruceM - 08 Jun 2007 18:08 GMT
It's rather difficult to see just what you are trying to do, but here are a
few things I noticed.  You need to use the IIf function in this case.  With
IIf you do not use quotes around field names as you would with a domain
function:

=DSum(IIff([CDDiscountDP] =
1,[CDDiscountAmount]*[CDQuantity],[CDFinalPrice]*[CDQuantity]*[CDDiscountPercent],
_
   "tblChecks","[CDCheckID] = " & [Forms]![frmCheckPreview]![TxtSalesID] &
" AND " & [CDItemID] > 42 & "")

Note that the underscore is just for convenience in posting here; you would
not use it in an expression (although you can use it for line breaks in
VBA).

Note that I changed the format of the AND part of the expression.  The
expression I suggested assumes that CDItemID is a number field.  If it is a
text field, I think the end part of the expression would be " AND """
[CDItemID] > 42 & """".  I need to say that I am not quite as sure as I
would like to be about the strings of quote marks.

I also need to stress that although I can recognize some syntax problems,
I'm not sure what you are trying to do, so I can't say if my suggestions
will work.  I don't see how the expression in your most recent post can be
evaluating CDItemID, since CDItemID is within the quotes, and therefore part
of the text string that includes the word AND.

>>> How can I combine these two statements into one?
>>> Thanks
[quoted text clipped - 19 lines]
> CDQuantity","tblCheckDetails","[CDCheckID]= " &
> [Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID] =31"),0)
DS - 10 Jun 2007 03:52 GMT
> It's rather difficult to see just what you are trying to do, but here are a
> few things I noticed.  You need to use the IIf function in this case.  With
[quoted text clipped - 47 lines]
>>CDQuantity","tblCheckDetails","[CDCheckID]= " &
>>[Forms]![frmCheckPreview]![TxtSalesID] & " AND [CDItemID] =31"),0)

Thanks, this has gotten me on my way!
DS
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.