Count Number of Deposits

  • Thread starter Gulf Coast Electric
  • Start date
G

Gulf Coast Electric

I have a form named Deposit Slip where I enter the cash amount of the
deposit and 9 other deposits that make up the total deposit.
The field used for cash deposit is named cash
the other 9 are named Dep1 thru Dep9
The field where the total for these is named Number of Deposits
this should show the total number of deposits made if there is data in them
they automatically show $0.00
can this be done?
Access 2002 service pack 3 with db in access 2000 format
 
D

Duncan Bachen

I have a form named Deposit Slip where I enter the cash amount of the
deposit and 9 other deposits that make up the total deposit.
The field used for cash deposit is named cash
the other 9 are named Dep1 thru Dep9
The field where the total for these is named Number of Deposits
this should show the total number of deposits made if there is data in them
they automatically show $0.00
can this be done?
Access 2002 service pack 3 with db in access 2000 format

You have to do something to check whether there is information in
them.

Air code:

Function GetNumDeposits() as Integer
Dim intCount as Integer

intCount = 0
If [Dep1] <> 0 and Not isnull([Dep1]) Then intCount = intCount +1
If [Dep2] <> 0 and Not isnull([Dep2]) Then intCount = intCount +1
If [Dep3] <> 0 and Not isnull([Dep3]) Then intCount = intCount +1
...
If [Dep9] <> 0 and Not isnull([Dep9]) Then intCount = intCount +1

GetNumDeposits = intCount
End Function

Then in the after update event of each of the Dep# fields, add this
line of code

txtNumDeposits = GetNumDeposits


Then anytime you update a deposit field, it will count all the other
fields to see if they have values, and then update your count
accordingly.



-D
 
G

Gulf Coast Electric

The Module errors out and says it cant find Dep1

What can I do or try?
I named the Module ModDepositCount



--
-------------------------------------------------------------------------
Thanks for your Help.
Duncan Bachen said:
I have a form named Deposit Slip where I enter the cash amount of the
deposit and 9 other deposits that make up the total deposit.
The field used for cash deposit is named cash
the other 9 are named Dep1 thru Dep9
The field where the total for these is named Number of Deposits
this should show the total number of deposits made if there is data in them
they automatically show $0.00
can this be done?
Access 2002 service pack 3 with db in access 2000 format

You have to do something to check whether there is information in
them.

Air code:

Function GetNumDeposits() as Integer
Dim intCount as Integer

intCount = 0
If [Dep1] <> 0 and Not isnull([Dep1]) Then intCount = intCount +1
If [Dep2] <> 0 and Not isnull([Dep2]) Then intCount = intCount +1
If [Dep3] <> 0 and Not isnull([Dep3]) Then intCount = intCount +1
...
If [Dep9] <> 0 and Not isnull([Dep9]) Then intCount = intCount +1

GetNumDeposits = intCount
End Function

Then in the after update event of each of the Dep# fields, add this
line of code

txtNumDeposits = GetNumDeposits


Then anytime you update a deposit field, it will count all the other
fields to see if they have values, and then update your count
accordingly.



-D

---------------------
Duncan Bachen (dbachen@NOSPAM_olehansen.com)
Director of IT
Ole Hansen and Sons Inc.
---------------------
 
D

Duncan Bachen

The Module errors out and says it cant find Dep1

What can I do or try?
I named the Module ModDepositCount

My code was designed to work within the form itself, as you indicated
you were working on in your original question.

It's not designed to work in a stand alone module, and as such, that
module doesn't know how to reference the field [Dep1]. It only exists
on the form.

Try placing that code behind your form for the results you want.



-D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top