"Mr. Smith" <Mr.Smith@Large> wrote in
news:40***********************@news.syd.swiftdsl.c om.au:
Pathfinder wrote: Hi All
I am trying to run the below but I receive the following
error "runsql action requires an argument consisting of an
SQL statment"
Dim MySQL$
MySQL$ = "Select * from mytablename"
DoCmd.RunSQL MySQL$
Any reason for that
Thanks
It may be that you have not explicitly defined the MYSQL$
variable's type.
Baloney. dim mysql$ does define the variable as a string. it's an
obsolete way, but it still works.
Have you tried?:
Dim MySQL$ As String
The docmd.runSQL command IS expecting a string variable and
maybe its tripping up because its not explicitly a string
('cause its a var)
Baloney.a variant works.
Alternately, maybe the $ is causing a problem. Just guessing
on that one
You don't have to guess anymore. the real reason the original
poster is getting nowhere is that runSQL doesn't return records.
The statement being run does return records and therefore cannot
work
From the help file on the RunSQL method:
A string expression that's a valid SQL statement for an action
query or a data-definition query.
Bob Quintal