Compile Error: Expected: = (1 Viewer)

M

MaxNEMC

Guest
I wrote a function that I want to have 3 parameters for

Import_Reports(tblName as String, Specs as String, InputDir as String)

When i try to run it, i get:
Compile Error: Expected =

BUT
If i define 2 of the parameters within the function as vars, leaving only one as an argument, it works fine. I can use any one of the 3 alone as an argument and it works, but any more than 1 and i get that compile error...
i'm stumped! :confused:

Any help would be greatly appreciated!

Max
 

Fornatian

Dim Person
Local time
Today, 08:34
Joined
Sep 1, 2000
Messages
1,396
Max,

A compile error of this nature means that a variable is missing an assignment somewhere. Can you post your code?

Also, can you elaborate on..

If i define 2 of the parameters within the function as vars, leaving only one as an argument...
 
M

MaxNEMC

Guest
Function Import_Reports(Specs As String, tblName As String, InputDir as string)
Dim ImportFile, ImportErrors As String
'Dummy As Integer

'InputDir = "c:\windows\desktop\adhocrpts\"

'Specs = "Highland Import Specs"

ImportFile = Dir(InputDir & "\*.txt") 'Sets the Filename to be imported

Do While Len(ImportFile) > 0

'tblName = Left(ImportFile, (InStr(1, ImportFile, ".") - 1)) 'This is to import each file into individual tables
'tblName = "Highland_Raw"

DoCmd.TransferText acImportFixed, Specs, tblName, InputDir & ImportFile, False

'DoCmd.RunMacro "Highland"
'DoCmd.DeleteObject acTable, tblName

ImportErrors = (Left(ImportFile, (InStr(1, ImportFile, ".") - 1)) & "_ImportErrors")
DoCmd.DeleteObject acTable, ImportErrors

ImportFile = Dir
Loop


----------------------------
heh, sorry about that....
what i mean is, if instead of having 3 parameters to be passed to the function, if i only give it one and then define the other 2 as string variables and assign them their values within the body of the function, then the code works....
 

Drevlin

Data Demon
Local time
Today, 08:34
Joined
Jul 16, 2002
Messages
135
I don't believe the problem is with your function. The problem is more likely with how you call the function.

If you're calling your function like this:

Sub RunFunction()
Import_Reports("Highland Import Specs", "tblMyTable", "c:\windows\desktop\adhocrpts\")
End Sub


You will get the "Expected =" error.
You won't get the error if you only have one variable:

Sub RunFunction()
Import_Reports("Highland Import Specs")
End Sub

Try calling the function like this instead:

Sub RunFunction()
Import_Reports "Highland Import Specs", "tblMyTable", "c:\windows\desktop\adhocrpts\"
End Sub
 

Users who are viewing this thread

Top Bottom