Re: SQL statement with extra characters
From: Lynn Trapp (ltrappNoSpam_at_ltcomputerdesigns.com)
Date: 07/06/04
- Next message: Joe Guenther: "Exporting Files: length of directory name"
- Previous message: Ray Gurganus: "reading XML data"
- In reply to: db_slave: "Re: SQL statement with extra characters"
- Next in thread: db_slave: "Re: SQL statement with extra characters"
- Reply: db_slave: "Re: SQL statement with extra characters"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 6 Jul 2004 13:28:32 -0500
First of all, you cannot use the Execute method with a Select Query. It is
used for Action queries only. Second, The .Execute method is seeing the
value of output_dataSQL as a complete SQL string and is confused about the
concatenated value for output_fileSQL. If you are trying to send your query
to a spread*** or something, then use the DoCmd.OutputTo method.
--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
"db_slave" <dbslave@discussions.microsoft.com> wrote in message
news:FAA5785E-5764-43D8-8DA9-F80DC14EF1D2@microsoft.com...
> The user is viewing a form of a linked table that has been filtered. I am
adding a feature so that the user can output the filtered data. Using
DoCmd.OutputTo statement was way too slow. The statement below is
attempting to have the db server perform the query and output the data.
>
> Dim db As Database
> Dim output_dataSQL as String 'selection statement
> Dim outputfile as String
> Dim output_fileSQL 'output statement
>
> Set db = OpenDatabase("", False, False, "ODBC;DSN=AP_system;" &
"TABLE=DBA.inv_match_work")
> Call FilterForm
> output_dataSQL = "SELECT * FROM inv_match_work WHERE " + Me.Filter + ";"
> outputfile = InputBox("What file name?", "Output match table data")
> output_fileSQL = "output to '" + outputfile + "';"
> db.Execute output_dataSQL + output_fileSQL
>
> Thanks Greg
>
>
> "Lynn Trapp" wrote:
>
> > It would really help if you would post your code.
> >
> > --
> > Lynn Trapp
> > MS Access MVP
> > www.ltcomputerdesigns.com
> > Access Security: www.ltcomputerdesigns.com/Security.htm
> >
> >
> > "db_slave" <dbslave@discussions.microsoft.com> wrote in message
> > news:FECF9736-6DEF-408C-86E3-C8CD142EE9C4@microsoft.com...
> > > I am using VB to compose a SQL select statement to an ODBC connected
> > database server. It returns an error "Run time error 3142 Characters
found
> > after end of SQL statement". I have double checked SQL statement used
and
> > it works fine when I run the statement on the database itself. I am
> > thinking there is something being added by the ODBC driver. Has anyone
else
> > encountered this?
> > >
> > > Thanks
> > > Greg
> >
> >
> >
- Next message: Joe Guenther: "Exporting Files: length of directory name"
- Previous message: Ray Gurganus: "reading XML data"
- In reply to: db_slave: "Re: SQL statement with extra characters"
- Next in thread: db_slave: "Re: SQL statement with extra characters"
- Reply: db_slave: "Re: SQL statement with extra characters"
- Messages sorted by: [ date ] [ thread ]