Compile Error Variable not defined

mkdrep

Registered User.
Local time
Today, 14:39
Joined
Feb 6, 2014
Messages
181
I have developed a quote form that is working well. I want to print out a Quotation to send to my customer. Currently it shows the Qty, Item ID# and description in the detail portion of report.

In the report footer, currently it will print out, Subtotal, Freight and the resulting total.

A problem arose when I tried to add the total weight of the items in a quote to the report form.

I get a "compile error...variable undefined" msg when I try to open up the report by clicking a "Print Report" button I have on the form.

Here is the code that is highlighted by the error msg. the Undefined variable is dWtTotal n red below.

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Me!txtSubTotal = dSubTotal
Me!txtDiscountValue = dDiscVal
Me!txtTotal = dTotal
Me.txtFreight = dFreight
' Me!txtTotalWithWork = dWithWork
'12-21-14 Add Total Job Wt to Report
Me.txtWttotal = dWtTotal

I feel like I have defined the variable with this code below which is in the first part of the VBC code that occurs when I click on the Print Quote button:

dSubTotal = 0
dDiscVal = 0
dTotal = 0
dWithWork = 0
dPkgPrice = 0
dTotPkg = 0
dDisc = 0
dVatVal = 0
dVatRate = 0
dFreight = 0
'Added 12-20-14
dWtTotal = 0

Thank you in advance for the help! :)
 
declare your variables

Inside your sub/function:
Dim myVar as ....

Outside as private in a form's or report module:
Private myVar as ...

as public, in a module:
Public myVar as ....
 
... and use Option Explicit property for your code.
 

Users who are viewing this thread

Back
Top Bottom