Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 01-14-2003, 11:04 AM   #1
MaxNEMC
Guest
 
Posts: n/a
Compile Error: Expected: =

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!

Any help would be greatly appreciated!

Max

  Reply With Quote
Old 01-14-2003, 11:49 AM   #2
Fornatian
Dim Person
 
Fornatian's Avatar
 
Join Date: Aug 2000
Location: England
Posts: 1,396
Thanks: 0
Thanked 4 Times in 3 Posts
Fornatian is on a distinguished road
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..

Quote:
If i define 2 of the parameters within the function as vars, leaving only one as an argument...
__________________
Ian

build a better system and they'll build a better idiot.
Fornatian is offline   Reply With Quote
Old 01-14-2003, 11:58 AM   #3
MaxNEMC
Guest
 
Posts: n/a
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....

  Reply With Quote
Old 01-14-2003, 12:57 PM   #4
Drevlin
Data Demon
 
Drevlin's Avatar
 
Join Date: Jul 2002
Location: Durham, NC USA
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
Drevlin
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
__________________
DISCLAIMER:
Any statement made by the above party is not guaranteed to be correct. Just because the afore-mentioned party thinks he knows the right way, does not necessarily mean he does.
------------------------
Drevlin is offline   Reply With Quote
Old 01-15-2003, 10:07 AM   #5
MaxNEMC
Guest
 
Posts: n/a
Yup, that was it Thank you!

  Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 11:58 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World