Re: Query an external database...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: DIOS (sindizzy_at_softhome.net)
Date: 02/17/04


Date: 17 Feb 2004 11:12:52 -0800

Well, I reviewed the SQL and it looks like so:

    sSQL = "INSERT INTO tblEmployees (FullName, Initials) " & _
           "SELECT EmpNme, Init " & _
           "FROM tblEmployees " & _
           "IN '" & sOldDBPath & "';"

    CurrentDb.Execute sSQL

When I run this inside my Access VBA code I get the error:
Runtime error 3134
Syntax error in INSERT INTO statement.

There has to be a way of doing this. It seems like a simple query to
me but I just cant get the right syntax down to work properly.

AGP

"DIOS" <sindizzy.pak@softhome.net> wrote in message news:<0iiXb.176439$U%5.838579@attbi_s03>...
> I apologize. The error reported is a synatx error in SQL statement.
> I must have skipped that space after the Init field. let me try that
> and see how it turns out.
>
> AGP
>
> --
>
> **********************************************************************
> Unpak my email address before sending me personal email
> **********************************************************************
>
> "Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
> news:esjd$dl8DHA.2524@TK2MSFTNGP11.phx.gbl...
> > "DIOS" <sindizzy@softhome.net> wrote in message
> > news:7d00f3c.0402130810.713699fe@posting.google.com
> > > I think that almost works except that my fields are named differently
> > > so Im trying this and it doesnt seem to work. I can feel im close, i
> > > just have to get the synatax right:
> > >
> > > sSQL = "INSERT INTO tblGroup (FullName, Initials) " & _
> > > "SELECT EmpNme, Init" & _
> > > "FROM tblGroup " & _
> > > "IN '" & sOldDBPath & "';"
> > >
> > > CurrentDb.Execute sSQL
> > >
> > >
> > > Its almost driving me insane. I know this should be a pretty easy
> > > query but i just cant get it to work right. Ive looked at the help and
> > > ive searche don google.
> >
> > You must get in the habit of stating exactly what error message you get,
> > or how the outcome is different from your expectations, instead of
> > simply saying "it doesn't seem to work." In this case, the only thing I
> > see that is still wrong in the statement you posted is that you have no
> > space after the field name "Init". Try this corrected version:
> >
> > sSQL = "INSERT INTO tblGroup (FullName, Initials) " & _
> > "SELECT EmpNme, Init " & _
> > "FROM tblGroup " & _
> > "IN '" & sOldDBPath & "';"
> >
> > and report the result.
> >
> > --
> > Dirk Goldgar, MS Access MVP
> > www.datagnostics.com
> >
> > (please reply to the newsgroup)
> >
> >



Relevant Pages

  • Re: Query an external database...
    ... When I run this inside my Access VBA code I get the error: ... Syntax error in INSERT INTO statement. ... The error reported is a synatx error in SQL statement. ... > Unpak my email address before sending me personal email ...
    (microsoft.public.access.queries)
  • Re: Query an external database...
    ... When I run this inside my Access VBA code I get the error: ... Syntax error in INSERT INTO statement. ... The error reported is a synatx error in SQL statement. ... > Unpak my email address before sending me personal email ...
    (microsoft.public.vb.general.discussion)
  • Re: XML vs SQL Server
    ... The built in factory assumes a common syntax among the ... the DBProvider Factory pattern is an interface-based ... Even if your SQL needs to be changed, ... change the value of the CommandText and everything else is fine. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Connection.Execute causes untrappable runtime error
    ... Set Recordset = Database.Execute ... If I want to do a delete or Update, I do a Database.Execute ("SQL Syntax") ... I believe that the dataenvironment is the best thing in vb6 (The program are ...
    (microsoft.public.vb.database.ado)
  • Re: Difference in Left Join, Right Join
    ... RIGHT syntax exist. ... If you write SQL such that what you feel is the driving table is at ... The above is Oracle outer join syntax, ...
    (comp.databases.oracle.misc)