A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Syntax error in append query



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2009, 11:27 AM posted to microsoft.public.access.queries
Frank Situmorang[_3_]
external usenet poster
 
Posts: 61
Default Syntax error in append query

Hello,

I can not save my following append query, with the error message " Syntax
error on INSERT INTO statement.

I presume because I wrongly name my field " Region Name_E" with space. How
can I remedy this, my church database already go live, how ever I want to
make kind of an append query for update when there is a consolidation.

Thanks for any help,

Frank

INSERT INTO tblRegions ( RegionID,Region Name_E, Region Name_L, RAddress1,
RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress)
SELECT a.RegionID, a.Region Nam_E, a.Region Name_L, a.RAddress1,
a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax,
a.RemailAddress
FROM [C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.md b].tblRegions AS a
WHERE (((Exists (SELECT *
FROM tblRegions
WHERE tblRegions.RegionID = a.RegionID))=False));
  #2  
Old July 2nd, 2009, 12:52 PM posted to microsoft.public.access.queries
Dale_Fye via AccessMonster.com
external usenet poster
 
Posts: 128
Default Syntax error in append query

Frank,

Whenever you have a space in a table or field name, you must wrap it in
brackets [ ].

I also think it will probably be more efficient to use an Outer Join to
identify the regions that don't already exist in the table you are trying to
insert into.

So, try:

INSERT INTO tblRegions (RegionID,[Region Name_E], [Region Name_L],
RAddress1, RAddress2, Rcity, Rregion,
RpostalCode, RCountry, RPhone, RFax,
RemailAddress)
SELECT a.RegionID, a.[Region Nam_E], a.[Region Name_L], a.RAddress1,
a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry,
a.RPhone, a.RFax, a.RemailAddress
FROM tblRegions IN "C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.m db" AS a
LEFT JOIN tblRegions
ON a.RegionID = tblRegions.RegionID
WHERE tblRegions.RegionID IS NULL

HTH
Dale

Frank Situmorang wrote:
Hello,

I can not save my following append query, with the error message " Syntax
error on INSERT INTO statement.

I presume because I wrongly name my field " Region Name_E" with space. How
can I remedy this, my church database already go live, how ever I want to
make kind of an append query for update when there is a consolidation.

Thanks for any help,

Frank

INSERT INTO tblRegions ( RegionID,Region Name_E, Region Name_L, RAddress1,
RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress)
SELECT a.RegionID, a.Region Nam_E, a.Region Name_L, a.RAddress1,
a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax,
a.RemailAddress
FROM [C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.md b].tblRegions AS a
WHERE (((Exists (SELECT *
FROM tblRegions
WHERE tblRegions.RegionID = a.RegionID))=False));


--
HTH

Dale Fye

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200907/1

  #3  
Old July 3rd, 2009, 03:02 AM posted to microsoft.public.access.queries
Frank Situmorang[_3_]
external usenet poster
 
Posts: 61
Default Syntax error in append query

Thanks Dale, since I have a button for running an append query, I think I
would prefer to use append query.

Thanks for your help.

Frank

"Dale_Fye via AccessMonster.com" wrote:

Frank,

Whenever you have a space in a table or field name, you must wrap it in
brackets [ ].

I also think it will probably be more efficient to use an Outer Join to
identify the regions that don't already exist in the table you are trying to
insert into.

So, try:

INSERT INTO tblRegions (RegionID,[Region Name_E], [Region Name_L],
RAddress1, RAddress2, Rcity, Rregion,
RpostalCode, RCountry, RPhone, RFax,
RemailAddress)
SELECT a.RegionID, a.[Region Nam_E], a.[Region Name_L], a.RAddress1,
a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry,
a.RPhone, a.RFax, a.RemailAddress
FROM tblRegions IN "C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.m db" AS a
LEFT JOIN tblRegions
ON a.RegionID = tblRegions.RegionID
WHERE tblRegions.RegionID IS NULL

HTH
Dale

Frank Situmorang wrote:
Hello,

I can not save my following append query, with the error message " Syntax
error on INSERT INTO statement.

I presume because I wrongly name my field " Region Name_E" with space. How
can I remedy this, my church database already go live, how ever I want to
make kind of an append query for update when there is a consolidation.

Thanks for any help,

Frank

INSERT INTO tblRegions ( RegionID,Region Name_E, Region Name_L, RAddress1,
RAddress2, Rcity, Rregion, RpostalCode, RCountry, RPhone, RFax, RemailAddress)
SELECT a.RegionID, a.Region Nam_E, a.Region Name_L, a.RAddress1,
a.RAddress2, a.Rcity, a.Rregion, a.RpostalCode, a.RCountry, a.RPhone, a.RFax,
a.RemailAddress
FROM [C:\Churchdata\Churchdataconso\BkEnd\Hahomion_be.md b].tblRegions AS a
WHERE (((Exists (SELECT *
FROM tblRegions
WHERE tblRegions.RegionID = a.RegionID))=False));


--
HTH

Dale Fye

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200907/1


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.