• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 482
  • Last Modified:

Invoice Total VB Function

I would like to create a function in VB.  I never wrote or used functions before.  Here is the situation:
I have two tables:  Invoice table & Account Receivables Table. Here are the fields:
Invoice Table:  Invoice#, Date,(all customer Info fields), Total Labor.
A/R Table: Invoice#, Date, (all customer Info fields), Late Charge, Amount Paid.

I would like to have a Function to calculate the Total Invoice Balance so I can put it in several forms.  
Here is the calculation:

([Invoice table]![Total Labor])+([Account Receivables Table]![Late Charges])-([Account Receivables Table]![Amount Paid])

I have no idea how to do this.  Any help will be appreciated.

Thanks!!

Alexander!!!

0
Millos
Asked:
Millos
  • 3
  • 2
1 Solution
 
mrmickCommented:
Function InvoiceTotal() As Long

   InvoiceTotal = ([Invoice table]![Total Labor]) + ([Account Receivables Table]![Late Charges]) - ([Account Receivables Table]![Amount Paid])

End Function

Usage:
Debug.Print InvoiceTotal

This will print the Invoice total for the current record.
0
 
MillosAuthor Commented:
mrmick: Thanks.. I tried creating the function (Which is the first time) and get an Invalid Object Reference in the following line (Tables!([Invoice table]![Total Labor]) and it highlights ([Invoice Table]

That is the correct name of the invoice table.  Do I have to declare the DB I am using?
Thanks!!
Alexander!!
   
Agongora@voicenet.com


0
 
MillosAuthor Commented:
Adjusted points to 60
0
 
mrmickCommented:
Millos, If you're now satisfied with the answer you've received - you should grade it.
0
 
mrmickCommented:
Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now