Runtime Error '3139' - Syntax Error in Parameter clause (1 Viewer)

theracer06

New member
Local time
Today, 01:19
Joined
May 14, 2010
Messages
3
Hi,

I inherited a simulation and when trying to run it I get the infamous runtime error 3139. Read it might be a form error for code created in Access 2003 and not conform to Access 2007 formulation. The code is the following:

Public Function RunAnnualSimulation(Country As Long, Year As Long, Iter As Long)

MOCSCollection.RunAnnualSimulation Country, Year, Iter
StoredYear = Year
StoredCountry = Country
Form_MOCG.txtStatusText.Value = "ready"

End Function


Can anybody help?

Thanks & Best
 

DCrake

Remembered
Local time
Today, 00:19
Joined
Jun 8, 2005
Messages
8,632
As long as you keep the functionality of the function to yurself the longer it will take for someone to make a suggestion.

What does the function do?
 

theracer06

New member
Local time
Today, 01:19
Joined
May 14, 2010
Messages
3
Ok sorry,

the function is meant to gather data for curves across different regions and different countries to calculate price information on an hourly or yearly basis and is followed by the following one:


Public Function ComputeMeritOrderCurveForTimeslot(Country As Long, Year As Long, Day As Date, Time As Date)

If (Country <> StoredCountry Or Year <> StoredYear) Then
Debug.Print "Creating Full Annual Series for " & Country & ", " & Year & "(StoredCountry=" & StoredCountry & ", StoredYear=" & StoredYear & ")"

' First, compute hours of operation of each plant
' to be able to compute base & max case costs
MOCSCollection.RunAnnualSimulation Country, Year, -1
StoredYear = Year
StoredCountry = Country

End If

MOCSCollection.CenterMOCS.ComputeMeritOrderCurveForTimeslot Country, Year, Day, Time, MOCSCollection.MOCSCollection
End Function
 

boblarson

Smeghead
Local time
Yesterday, 16:19
Joined
Jan 12, 2001
Messages
32,059
You are trying to use YEAR as a parameter. It is an Access Reserved Word. That is one reason your variables SHOULD have a prefix to them. Like

lngYear As Long
 

theracer06

New member
Local time
Today, 01:19
Joined
May 14, 2010
Messages
3
Hi Bob,

thanks for the clarification.

When you say that I need to change the paramenter, do you mean it as follows?

Public Function RunAnnualSimulation(Country As Long, IngYear As Long, Iter As Long)

MOCSCollection.RunAnnualSimulation Country, IngYear, Iter
StoredYear = IngYear
StoredCountry = Country
Form_MOCG.txtStatusText.Value = "ready"

End Function

Because unfortunately I keep on getting the same error...
 

boblarson

Smeghead
Local time
Yesterday, 16:19
Joined
Jan 12, 2001
Messages
32,059
Yes that is what I meant but not with an I but with an L - lngYear where lng is long without the o.

But I'm also looking at your function and it looks like you are trying to call the same function you are in.

Isn't the part in read calling the same function it is in (in blue)?
Code:
Public Function [COLOR="Blue"]RunAnnualSimulation[/COLOR](Country As Long, IngYear As Long, Iter As Long)

MOCSCollection.[COLOR="Red"][B]RunAnnualSimulation[/B][/COLOR] Country, IngYear, Iter
StoredYear = IngYear
StoredCountry = Country
Form_MOCG.txtStatusText.Value = "ready"

End Function

Also, to refer to the form MOCG you should use

Forms!MOCG.txtStatusText = "ready"

and not Form_
 

Users who are viewing this thread

Top Bottom