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 / March 2007

Tip: Looking for answers? Try searching our database.

DSum Criteria Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MF Scheetz - 08 Mar 2007 19:21 GMT
I've got one table that lists contract payments for multiple monthly
payments.  Each record has contract number, payment date, payment amount

In another table I have all the contract info: contract number, contract
name, contract city, contract description, etc.

The total yearly amount per city of all the contracts has a cap, $25mil.  So
I want to run an If..Else..(I'll take care of that) for any new contracts
that go over the cap for any city/fiscal year they are added to.

I am trying to create a dsum() where the criteria includes both the payment
year (I've got that down) AND also the current record's city (from the other
table).

Right now I've got:

   Dim Year As Integer               'Starting with first payment's year
   Dim City As String
   Dim YrTot as Integer              'Yearly total for selected city

   Year = Format(DMin("dteBegin", "tblDR", "[txtLoanNo]='" & Me.cboLoanNo &
"' AND [intDR]=0"), "YYYY")
   City= DLookup("txtCity", "tblGenLoanInfo", "[txtLoanNo]='" &
Me.cboLoanNo & "'")

Now how would I make:
   YrTot = DSum("intPayment","tblDR", "[dteBegin] Like '*'&" & Year & " AND
[tblGenLoanInfo].[txtCity]= '"& City &"'")  - I know this doesn't work

Any help is greatly appreciated.

-Matt
Ofer Cohen - 08 Mar 2007 20:19 GMT
First Year is a reserved word in Access  , so use aother word

Dim MyYear As Integer              

Then try instead of using like

YrTot = DSum("intPayment","tblDR", "Year([dteBegin]) = " & MyYear & " AND
[tblGenLoanInfo].[txtCity]= '" & City & "'")  - I know this doesn't work

Signature

Good Luck
BS"D

> I've got one table that lists contract payments for multiple monthly
> payments.  Each record has contract number, payment date, payment amount
[quoted text clipped - 28 lines]
>
> -Matt
MF Scheetz - 08 Mar 2007 21:35 GMT
Thanks.  But that still doesn't help solve the real problem, Getting the
DSum() based on data from 2 tables.

I know I can create a query to run the DSum() off of, but I was wondering if
there was another way to make this work.

-Matt

> First Year is a reserved word in Access  , so use aother word
>
[quoted text clipped - 37 lines]
> >
> > -Matt
 
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.