Link to home
Start Free TrialLog in
Avatar of Arkawa72
Arkawa72Flag for Netherlands

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)


Avatar of Norie
Norie

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.
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.