Reputation: 1
I have a VBA function that worked fine, until I tried to pass an extra variable to it. Now the code won't run, and I get an error stating Expected:=, I've tried renaming the function, but no help.
Was - Function GetData(site_add) Changed to Function GetData(site_add, temporary) and failed - despite changing the call to the function accordingly...!?!
Is it possible that the compiler is glitching and I should focus on that? I have other functions in the code that use 5 call 5 variables and don't even call/use them all...!? Help...
Upvotes: 0
Views: 110
Reputation: 1
As old as the original question is, I believe I know the solution. (Still a top result though, apparently. As I just recently ran in to this very issue and had to Google it, which brought me here.) It's simple, but really aggravating when you forget this tiny detail (like I did, and often do.)
After finding this post, I just randomly remembered something: If it's one parameter, the parenthesis () around the information works fine. But with two or more parameters, for some reason (can't remember what at this point) the parenthesis throws a monkey wrench into things, and has to be left off.
I tried that, and the goofy error(s) went away.
So, it should work if you write it as:
GetData site_add, temporary
Upvotes: 0
Reputation: 2876
By adding the second parameter, you are effectively telling the compiler that every call to this method now requires two parameters instead of one. So you have to find everywhere you call the GetData() function and make sure it now passes two parameters instead of one, even if the second parameter is Nothing. Now, if you want it to default to nothing so you don't need to pass it you can rewrite it as
GetData(site_add, Optional temporary)
*my vb is rusty, so take my example with a grain of salt please.
Upvotes: 1