trying to SUM rs in Textbox from criteria

G

Gator

I want Text27 to show SUM of all the numbers in the Field 'Amount' in Table
'Deposits' based on the value of List7.Column(2) that is selected on each
click event on List7. Below is the code I have tried (Compile error:
Type-declaration character does not match declared data type) at the Line
beginning with "Me!Text27=". There may be better ways to do it and if there
are, I'm game. Keep in mind I have much to learn so help me as much as
possible. thanks

Private Sub List7_Click()
Me.Text11.Value = List7.Column(1)
Me.Text13.Value = List7.Column(2)
Me.Text15.Value = List7.Column(3)

Dim mycon As New ADODB.Connection
Dim rs As New ADODB.Recordset
Set mycon = CurrentProject.Connection
rs.Open "TreasurerDepositsQuery", mycon, adOpenKeyset, adLockBatchOptimistic
rs.Find "Fund='" & Me!List7.Column(2) & "'"
Me!Text27 = rs!(DSum("Amount", "Deposits"))
rs.Close
mycon.Close

End Sub
 
J

Jeff Boyce

Gator

Take a look at Access HELP for the syntax on using DSum(). I suspect you
are running into a problem because you are trying to assign a value for your
textbox that is a recordset (rather than the sum of a field/column from that
recordset).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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