Access VBA compile error

I get a "compile error: argument not optional" when I run the following macro in Access 2000

Echo = "SELECT * INTO Echo FROM Delta LEFT JOIN BookingOfficeregion ON Delta.bookingoffice=Bookingofficeregion.BookingOfficeDescription;"

DoCmd.RunSQL Echo

If I just run the query in the query menu, I get no errors. Any ideas?
Arkawa72Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
"Echo" is a vba function(method)

change it with something else

dim strEcho as string

strEcho= "SELECT * INTO Echo FROM Delta LEFT JOIN BookingOfficeregion ON Delta.bookingoffice=Bookingofficeregion.BookingOfficeDescription;"

DoCmd.RunSQL strEcho
0
 
mbizupCommented:
strEcho = "SELECT * INTO Echo FROM Delta LEFT JOIN BookingOfficeregion ON Delta.bookingoffice=Bookingofficeregion.BookingOfficeDescription;"

DoCmd.RunSQL strEcho

Open in new window

(Echo is a vba command.  Dont use it as a variable name)


0
 
NorieVBA ExpertCommented:
Don't use Echo for a variable name - it's an Access VBA method.

Try something like strSQL - it kind of tells you what the variable is for.
0
 
mbizupCommented:
Generally, you should pick your variable names carefully, and give them meaningful prefixes to avoid problems like this.

For example, prefix integer names with 'int', string with 'str', textboxes with 'txt'... etc)

intMyinteger
strMyString
txtMyTextbox
cboMyComboBox

Take a look at these standards (many of the Experts here use these):
http://www.xoc.net/standards/rvbanc.asp

Naming conventions specific to Access are midway down the page.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.