# I don't understand this VBA error I'm getting.

This topic is 4481 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm just trying to write a function for an Access module that concatenates two strings together, and then uses the result as the pathname for a shell command. Here's what it looks like now:
Function ConvertWav2AT3()

Dim prjPath As String
Set prjPath = Environ\$("PROJECT_PATH")

Dim shellPath As String
Set shellPath = "C:\program.exe -e _
" & prjPath & "\src.foo c:\dest.foo"

Shell(shellPath, 1)

End Function

So you can see that "program.exe" takes on various arguments, including a destination file name and a source filename. The source file name depends on the person's PROJECT_PATH environment variable, and so I can't just set it here. I have to "concatenate" it into the source path. After typing in the Shell(shellPath, 1) function, I get an error that says:
Compile Error:
Expected: =

I have no idea what it's asking for. I though maybe it needed me to named the arguments, so I tried Shell(pathname:=shellPath, windowstyle:=1) and I still get the same error. Any ideas?

##### Share on other sites
Which version of Access are you using? Different versions have different VBA versions that accept slightly different syntax.

##### Share on other sites
It's 2003. I was able to "fix" it by removing the parenthesis. I'm not sure why, though.

##### Share on other sites
Of course, now when I run the module, I get another error I don't understand:
Compiler error:Object required

When I click "Ok", the "prjPath =" part of the Set statement is highlighted as though I've clicked and dragged the mouse over it. Also, the very first line of the code (with the function name) is highlighted in yellow.

I want to learn how to do this, but it's frustrating to run into these errors whenever I try to do the simplest thing.

##### Share on other sites
It probably doesn't like the Set on that line. Take it off.

##### Share on other sites
Thanks, that worked. Now it's telling me that my call to Shell is invalid at runtime. I took away the "1" argument. That worked and I'm not sure why. But thanks again!

• 36
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631359
• Total Posts
2999538
×