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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't make Running sum to Work

Status
Not open for further replies.

gepol

Programmer
Jun 11, 2010
12
0
0
GR
Hello,

I have copied and adjusted the code from the FAQ: by TheAceMan1, but I seem to always get error in the control in Question.

My knowledge in VBA is not very good, so help would be deeply appreciated.

Forms name = Data (continuous forms)
Autonumber field = AA
Field that contains the values = Debit
Unbound box to show the running sum = Balance

The only thing that I have managed to accomplish is get an #error result very slowly populating the Balance text box.

What I actually want to do after I manage to make this work is to have a debit and credit balance result in my form.

Best regards

George
 
How are ya gepol . . .

Post the following code as you have it in your forms code module:
Code:
[blue]Private Function SubSum()
'*************************************************************
'* pkName   - Existing unique fieldname (usually primarykey) *
'* sumName  - Name of the field to runsum                    *
'*************************************************************
   
   If Trim(Me!pkName & "") <> "" Then 'Skip New Record!
      SubSum = frmRunSum(Me, "pkName", "sumName")
   End If

End Function[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Code:
Private Function SubSum()'*************************************************************'* pkName   - Existing unique fieldname (usually primarykey) *'* sumName  - Name of the field to runsum                    *'*************************************************************      If Trim(Me!AA & "") <> "" Then 'Skip New Record!      SubSum = frmRunSum(Me, "AA", "Debit")
End If
End Function
 
Sorry for the above mess, not very experienced in this forum...
 
gepol . . .

Did you type the code? ... or did you copy & paste?

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
gepol . . .

I copied and pasted your above post in Notepad, Word and access Visual Basic Editor. They all revealed a [blue]single line[/blue] with [red]no carriage returns/linefeeds[/red]. This is [blue]apparently how the code was entered [/blue]and is [red]very surprising for a programmer in any language[/red] (you do signin as a programmer!).

The code can not work this way ... you'll have to delete what you have, go back to the faq, copy then paste the code. When your done the code should look exactly like that in the faq ... perform your testing when done.

BTW: also copy/paste from Tek-Tips.

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Sorry theAceman1 but the code was copied from your own code in the previous post, and I manually changed the names of the fields and inserted the "[c0de][/code] afterwards. This forum does not offer editing of your own posts (unless I can't see an edit button), so I could not make it to look like correctly.

The code in the form is correct.
 
Test to see if it works..
Code:
Private Function SubSum()
'*************************************************************
'* pkName   - Existing unique fieldname (usually primarykey) *
'* sumName  - Name of the field to runsum                    *
'*************************************************************
   
   If Trim(Me!AA & "") <> "" Then 'Skip New Record!
      SubSum = frmRunSum(Me, "AA", "Debit")
   End If

End Function
 
gepol . . .

Great! [thumbsup2]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
No, you got me wrong. What worked is the way to paste the code correctly in this forum.

The form still produces the #error as per my first post in this thread [sadeyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top