External Name not defined??

gmatriix

Registered User.
Local time
Today, 08:04
Joined
Mar 19, 2007
Messages
365
Hello All,

I have this function and I can't get rid of this error:
"Compile error! External Name not defined"

This is just doing some calculations. I am just calling the function on the after update event on my form.

Any ideas??

Code:
Dim fHrs As Double
Dim Ttl As Double
Dim Ttl1 As Double
Dim Ttl2 As Double
Dim Ttl3 As Double
Dim Ttl4 As Double
Dim Ttl5 As Double
Dim Ttl6 As Double
Dim Ttl7 As Double

Dim AuditID As Long

Forms![Gera Audit]!Tue_Hrs = fHrs
Forms![Gera Audit]!Wed_Hrs = fHrs
Forms![Gera Audit]!Thu_Hrs = fHrs

    Forms![Gera Audit]!Fri_Hrs = fHrs
    Forms![Gera Audit]!GMon_Hrs = fHrs
    Forms![Gera Audit]!GTue_Hrs = fHrs
    
Forms![Gera Audit]!GWed_Hrs = fHrs
Forms![Gera Audit]!GThu_Hrs = fHrs
Forms![Gera Audit]!GFri_Hrs = fHrs

    Forms![Gera Audit]!Sat_Hrs = fHrs
    Forms![Gera Audit]!Sun_Hrs = fHrs
    Forms![Gera Audit]!GSat_Hrs = fHrs
    
Forms![Gera Audit]!GSun_Hrs = fHrs

Forms![Gera Audit]!GNew_Sensors = 0
Forms![Gera Audit]!GFix_Hrs_Adj_Wk = 0


Ttl = DSum(Forms![Gera Audit]![% Ballast] * Forms![Gera Audit]![Fixtures] * Forms![Gera Audit]![Ball Mat] + Forms![Gera Audit].Form![Ball Labor], "tblMainGera", [ID] = Forms![Gera Audit]!AuditID)
Forms![Gera Audit]!Ttl_Ballast_M_ = Ttl

Ttl1 = DSum(Forms![Gera Audit]![Input-Watts] * Forms![Gera Audit]![Fix Hrs Wk] * 52 / 1000, "tblMainGera", [ID] = Forms![Gera Audit]!AuditID)
Forms![Gera Audit]!kWh_Burn_Yr = Ttl1

Ttl2 = DSum(Forms![Gera Audit]![Lamp $] + Forms![Gera Audit]![Labor $] + Forms![Gera Audit]![Equipment $], "tblMainGera", [ID] = Forms![Gera Audit]!AuditID)
Forms![Gera Audit]!Ttl_Lamp_M_ = Ttl2 * Forms![Gera Audit]!Fixtures

Ttl3 = DSum([Lamp $] + [Labor $] + [Equipment $], "tblMainGera", [ID] = 1)
Forms![Gera Audit]!Ttl_Lamp_M_ = Ttl * Forms![Gera Audit]!Lamps / 2

Ttl4 = DSum([Mon-Hrs] + [Tue-Hrs] + [Wed-Hrs] + [Thu-Hrs] + [Fri-Hrs] + [Sat-Hrs] + [Sun-Hrs], "tblMainGera", [ID] = AuditID)
Ttl5 = DSum([GMon-Hrs] + [GTue-Hrs] + [GWed-Hrs] + [GThu-Hrs] + [GFri-Hrs] + [GSat-Hrs] + [GSun-Hrs], "tblMainGera", [ID] = AuditID)

Forms![Gera Audit]!Wrk_Hrs_Wk = Tt4
Forms![Gera Audit]!GWrk_Hrs_Wk = Ttl5

Ttl6 = DSum([Fixtures] * [Wrk_Hrs_Wk], "tblMainGera", [ID] = AuditID)
Forms![Gera Audit]!Fix_Hrs_Wk = Ttl6

Forms![Gera Audit]!GAdj_Fix_Hrs_Wk = Forms![Gera Audit]!GWrk_Hrs_Wk - Forms![Gera Audit]!GFix_Hrs_Adj_Wk

Ttl7 = DSum([GInput-Watts] * [GFixtures] * [GAdj_Fix_Hrs_Wk] * 52 / 1000, "tblMainGera", [ID] = AuditID)

Forms![Gera Audit]!GkWh_Burn_Yr = Ttl3 / 2

Forms![Gera Audit]!GkWh_Saved_yr = Forms![Gera Audit]!kWh_Burn_Yr - Ttl7

Forms![Gera Audit]!GPercentage_of_Energy_Saved = Forms![Gera Audit]!GkWh_Saved_yr / Forms![Gera Audit]!kWh_Burn_Yr
End Function
 
can see plenty - missing quotation marks in this line (added in red) plus similar other lines

Ttl4 = DSum("[Mon-Hrs] + [Tue-Hrs] + [Wed-Hrs] + [Thu-Hrs] + [Fri-Hrs] + [Sat-Hrs] + [Sun-Hrs]", "tblMainGera", "[ID] = AuditID")

Also, not clear from your code but

"[ID] = AuditID"

Maybe should be stated as

"[ID] = " & AuditID

In this one, why are you referring to form values in a dsum function and not to anything in tblMainGera?

Ttl = DSum(Forms![Gera Audit]![% Ballast] * Forms![Gera Audit]![Fixtures] * Forms![Gera Audit]![Ball Mat] + Forms![Gera Audit].Form![Ball Labor], "tblMainGera", [ID] = Forms![Gera Audit]!AuditID)

There are no doubt more, but I would address these first and see what is left as a problem
 
It also seems a little odd that you're apparently trying to set 13 Controls on the Form [Gera Audit] to the same Value, i.e. fHrs!

Perhaps a plain-language explanation of exactly what you're trying to do, here, is also in order!

Linq ;0)>
 
CJ,

Thanks for your response. I had this or part of the code on a control in the form on the after update event for example and it worked fine. I just copied the code from that contol and others because I wanted all the calculation to update at the same time.

It gave me an error when I ran it the first time. I couldnt figure out why it was not working so I add part of the code that refers to the form just to see if it made any difference. I am still learning so you will have to forgive me.

I will try to the quotes and let you know.

thanks
 

Users who are viewing this thread

Back
Top Bottom