Solved

Invoice Total VB Function

Posted on 1997-12-20
5
385 Views
Last Modified: 2010-05-18
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
Comment
Question by:Millos
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
mrmick earned 60 total points
ID: 1446368
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
 

Author Comment

by:Millos
ID: 1446369
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
 

Author Comment

by:Millos
ID: 1446370
Adjusted points to 60
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1446371
Millos, If you're now satisfied with the answer you've received - you should grade it.
0
 
LVL 8

Expert Comment

by:mrmick
ID: 1446372
Thanks.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now