Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access/VBA Programming Question

Status
Not open for further replies.

ill05nino

Programmer
Jul 14, 2010
1
US
Here is my dilemma;

I have 3 Columns;

Vendor -- CheckAmount -- CheckBox

AA -- 200 --
AA -- 250 --
AA -- 5000 --
BB -- 599.99 --
CC -- 150 --
DD -- 600 --
EE -- 200 --
EE -- 200 --
EE -- 200 --

What I need to have is, when the form loads, I need a script that runs that does some calculations. If a specific vendor has equal to or greater than $600 total, I need to check the box, FOR ALL OF THE SAME VENDOR. See below for what the form should look like when this script runs.

AA -- 200 -- X
AA -- 250 -- X
AA -- 5000 -- X
BB -- 599.99 --
CC -- 150 --
DD -- 600 -- X
EE -- 200 -- X
EE -- 200 -- X
EE -- 200 -- X

This is what I currently have, which only checks the boxes for a total of more than 599.99, I know I need to add more, or even try to make some sort of query that runs through the file and then checks the boxes for sums totaling more than 600 for each client. I just don’t know HOW to do that!

Here is what I currently have:

Dim rst As DAO.Recordset
Dim vc As Long

DoCmd.GoToRecord , , acFirst
Set rst = Me.RecordsetClone
rst.MoveFirst
Do While Not rst.EOF
vc = vc + 1
If vc > 1 Then DoCmd.GoToRecord , , acNext
If InvCheckAmount > 599.99 Then
[Inv1099Activity] = -1
End If
rst.MoveNext
Loop
DoCmd.GoToRecord , , acFirst
Me.Repaint
Set rst = Nothing
 



Why not a query?
Code:
Select Vendor, CheckAmount
From YourTable
Where Vendor IN 
(
Select Vendor 
From YourTableName 
Group By Vendor
Having SUM(CheckAmount)>=600
)
[code]


Skip,
[sub]
[glasses]Just traded in my old subtlety...
[b]for a NUANCE![/b][tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top