By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Convert Access append query to VBA Code

P: 10
Hello all,

I have a append query that works great if I just run the query via Access. I
need to convert that query into VBA code. Here is the SQL View of the query
I'm trying to convert:

INSERT INTO TblInitiator IN 'X:\Archive\TestFinal\080107\TS3000v101_be.mdb'
SELECT tblAddInitiator.*
FROM tblAddInitiator;

What the query does is append the table called tblInitiator located in a
network location from values in a table called tblAddInitiator. There is only
one field in each of the tables both called fldInitiator

I tried this VBA statement (all on 1 line)

AppendDB = "INSERT INTO 'TblInitiator' IN [I:\Archive\TestFinal\080107\
TS3000v101_be.mdb] SELECT 'tblAddInitiator.*' FROM 'tblAddInitiator';"

I get the message:
Syntax error in query. Incomplete query clause

What am I missing from the statement? Help!!

Thanks in advance,

Clarence
Aug 7 '07 #1
Share this Question
Share on Google+
3 Replies


FishVal
Expert 2.5K+
P: 2,653
Hello all,

I have a append query that works great if I just run the query via Access. I
need to convert that query into VBA code. Here is the SQL View of the query
I'm trying to convert:

INSERT INTO TblInitiator IN 'X:\Archive\TestFinal\080107\TS3000v101_be.mdb'
SELECT tblAddInitiator.*
FROM tblAddInitiator;

What the query does is append the table called tblInitiator located in a
network location from values in a table called tblAddInitiator. There is only
one field in each of the tables both called fldInitiator

I tried this VBA statement (all on 1 line)

AppendDB = "INSERT INTO 'TblInitiator' IN [I:\Archive\TestFinal\080107\
TS3000v101_be.mdb] SELECT 'tblAddInitiator.*' FROM 'tblAddInitiator';"

I get the message:
Syntax error in query. Incomplete query clause

What am I missing from the statement? Help!!

Thanks in advance,

Clarence
Hi, Clarence.

Try the following.

Expand|Select|Wrap|Line Numbers
  1. Docmd.RunSQL "<SQL statement exactly as it appears in query builder>"
  2.  
Aug 7 '07 #2

P: 10
Does it all have to be on one line??
Aug 7 '07 #3

P: 10
Does it all have to be on one line??

Fish,

I got it to work...thanks for your help today

Clarence
Aug 7 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.