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.



Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Function InvoiceTotal() As Long

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

End Function

Debug.Print InvoiceTotal

This will print the Invoice total for the current record.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?

MillosAuthor Commented:
Adjusted points to 60
Millos, If you're now satisfied with the answer you've received - you should grade it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.