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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL code works in Access SQL window but not in VBA SQL code



 
 
Thread Tools Display Modes
  #1  
Old August 10th, 2008, 04:56 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 308
Default SQL code works in Access SQL window but not in VBA SQL code

2003

The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
& " INTO CHOOSERev" _
& Chr(10) & "FROM CHOOSEData" & Chr(10) _
& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.

I guess the syntax I am using is incorrect after the .Execute command. (Note the . INTO CHOOSERev
10th line

Any help greatly appreciated!

EagleOne
  #2  
Old August 10th, 2008, 05:01 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 308
Default SQL code works in Access SQL window but not in VBA SQL code

Bottom line, I am attempting to create, in "dbs" project, a new table CHOOSERev from CHOOSEData

wrote:

2003

The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
& " INTO CHOOSERev" _
& Chr(10) & "FROM CHOOSEData" & Chr(10) _
& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.

I guess the syntax I am using is incorrect after the .Execute command. (Note the . INTO CHOOSERev
10th line

Any help greatly appreciated!

EagleOne

  #3  
Old August 10th, 2008, 05:30 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 87
Default SQL code works in Access SQL window but not in VBA SQL code

On Aug 10, 9:01*am, wrote:
Bottom line, I am attempting to create, in "dbs" project, a new table CHOOSERev from CHOOSEData



wrote:
2003


The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
* *"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
* *& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData..AAA_UIC, " _
* *& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
* *& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
* *& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
* *& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
* *& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
* *& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
* *& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
* *& " INTO CHOOSERev" _
* *& Chr(10) & "FROM CHOOSEData" & Chr(10) *_
* *& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.


I guess the syntax I am using is incorrect after the .Execute command. *(Note the . INTO CHOOSERev
10th line


Any help greatly appreciated!


EagleOne- Hide quoted text -


- Show quoted text -




Sometimes Access gives strange error messages.

I would look at the following:

--There is no space after " INTO CHOOSERev".
--There is a line-feed character before and after "FROM CHOOSEData".
--There is a semi-colon embedded in the sql string.
--There is a limit to the length of an sql statement and you are
wasting
part of that limited number of characters by repeating
"CHOOSEDATA.".
( I think the limit is 255 characters )


  #4  
Old August 10th, 2008, 05:31 PM posted to microsoft.public.access
John Spencer
external usenet poster
 
Posts: 2,364
Default SQL code works in Access SQL window but not in VBA SQL code

Try replacing Chr(10) with VbCRLF
or with
Chr(13) & Chr(10)


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX,
CHOOSEData.AAA_UIC, " _
& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, "
& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
& " INTO CHOOSERev" _
& vbcrlf & "FROM CHOOSEData" & vbcrlf _
& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And
((CHOOSEData.LTrim_REG)'7'));"

'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


wrote:
2003

The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
& " INTO CHOOSERev" _
& Chr(10) & "FROM CHOOSEData" & Chr(10) _
& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.

I guess the syntax I am using is incorrect after the .Execute command. (Note the . INTO CHOOSERev
10th line

Any help greatly appreciated!

EagleOne

  #5  
Old August 10th, 2008, 05:48 PM posted to microsoft.public.access
Michael Gramelspacher
external usenet poster
 
Posts: 482
Default SQL code works in Access SQL window but not in VBA SQL code

On Sun, 10 Aug 2008 09:30:25 -0700 (PDT), wrote:

On Aug 10, 9:01*am, wrote:
Bottom line, I am attempting to create, in "dbs" project, a new table CHOOSERev from CHOOSEData



wrote:
2003


The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
* *"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
* *& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
* *& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
* *& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
* *& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
* *& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
* *& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
* *& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
* *& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
* *& " INTO CHOOSERev" _
* *& Chr(10) & "FROM CHOOSEData" & Chr(10) *_
* *& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.


I guess the syntax I am using is incorrect after the .Execute command. *(Note the . INTO CHOOSERev
10th line


Any help greatly appreciated!


EagleOne- Hide quoted text -


- Show quoted text -




Sometimes Access gives strange error messages.

I would look at the following:

--There is no space after " INTO CHOOSERev".
--There is a line-feed character before and after "FROM CHOOSEData".
--There is a semi-colon embedded in the sql string.
--There is a limit to the length of an sql statement and you are
wasting
part of that limited number of characters by repeating
"CHOOSEDATA.".
( I think the limit is 255 characters )


try this

dbs.Execute _
" a.AAA_UIC, a.ACRN, a.AMT, a.DOC_NUMBER, a.FIPC," & _
" a.REG_NUMB, a.TRAN_TYPE, a.DOV_NUM, a.PAA," & _
" a.COST_CODE, a.OBJ_CODE, a.EFY, a.REG_MO, a.RPT_MO," & _
" a.EFFEC_DATE, a.Orig_Sort, a.LTrim_BFY, a.LTrim_AAA," & _
" a.LTrim_REG, a.LTrim_DOV, a.AMT_Rev, a.CONCACT" & _
" INTO [CHOOSERev] FROM [CHOOSEData]" & _
" WHERE (((a.TRAN_TYPE) IN ('1K','2D'))" & _
" AND ((a.LTrim_REG) '7'));"
  #6  
Old August 10th, 2008, 05:57 PM posted to microsoft.public.access
Michael Gramelspacher
external usenet poster
 
Posts: 482
Default SQL code works in Access SQL window but not in VBA SQL code

On Sun, 10 Aug 2008 11:48:32 -0500, Michael Gramelspacher wrote:

" INTO [CHOOSERev] FROM [CHOOSEData]" & _


should be:

" INTO [CHOOSERev] FROM [CHOOSEData] AS a" & _

  #7  
Old August 10th, 2008, 06:01 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 308
Default SQL code works in Access SQL window but not in VBA SQL code

Louis,

I made all of your suggested changes and I still get the same error.

A Da! epiphany may have occured in my mind.

I bet that a table is a RecordSet in a Project? No?

If so,

Set CHOOSEDRev = dbs.OpenRecordset("SELECT * FROM CHOOSEDATA Where (((CHOOSEData.TRAN_TYPE) In
('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'))") 'may be a solution?

To be more clear:

The VBA module is in "Tools.mdb"

So I am in Tools.mdb and have set currentdb to "Recon.mdb"

In Recon.mdb I have previously created a table "ChooseData"

I want to use "ChooseData" to create a new "ChooseRev" table in Recon.mdb

Then I close Recon.mdb and stay in "Tools.mdb" to create another Recon.mdb as Recon2.mdb.


wrote:

On Aug 10, 9:01*am, wrote:
Bottom line, I am attempting to create, in "dbs" project, a new table CHOOSERev from CHOOSEData



wrote:
2003


The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
* *"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
* *& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
* *& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
* *& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
* *& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
* *& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
* *& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
* *& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
* *& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
* *& " INTO CHOOSERev" _
* *& Chr(10) & "FROM CHOOSEData" & Chr(10) *_
* *& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.


I guess the syntax I am using is incorrect after the .Execute command. *(Note the . INTO CHOOSERev
10th line


Any help greatly appreciated!


EagleOne- Hide quoted text -


- Show quoted text -




Sometimes Access gives strange error messages.

I would look at the following:

--There is no space after " INTO CHOOSERev".
--There is a line-feed character before and after "FROM CHOOSEData".
--There is a semi-colon embedded in the sql string.
--There is a limit to the length of an sql statement and you are
wasting
part of that limited number of characters by repeating
"CHOOSEDATA.".
( I think the limit is 255 characters )

  #8  
Old August 10th, 2008, 06:09 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 308
Default SQL code works in Access SQL window but not in VBA SQL code

Mike,

Received an error that related to "a" as Could not find table "a"

Thanks

Michael Gramelspacher wrote:

" INTO [CHOOSERev] FROM [CHOOSEData] AS a" & _

  #9  
Old August 10th, 2008, 06:11 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 308
Default SQL code works in Access SQL window but not in VBA SQL code

I made all of your suggested changes and I still get the same error.

A Da! epiphany may have occured in my mind.

I bet that a table is a RecordSet in a Project? No?

If so,

Set CHOOSEDRev = dbs.OpenRecordset("SELECT * FROM CHOOSEDATA Where (((CHOOSEData.TRAN_TYPE) In
('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'))") 'may be a solution?

To be more clear:

The VBA module is in "Tools.mdb"

So I am in Tools.mdb and have set currentdb to "Recon.mdb"

In Recon.mdb I have previously created a table "ChooseData"

I want to use "ChooseData" to create a new "ChooseRev" table in Recon.mdb

Then I close Recon.mdb and stay in "Tools.mdb" to create another Recon.mdb as Recon2.mdb.

Any other thoughts?

What about

John Spencer wrote:

Try replacing Chr(10) with VbCRLF
or with
Chr(13) & Chr(10)


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX,
CHOOSEData.AAA_UIC, " _
& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, "
& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
& " INTO CHOOSERev" _
& vbcrlf & "FROM CHOOSEData" & vbcrlf _
& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And
((CHOOSEData.LTrim_REG)'7'));"

'================================================ ====
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================ ====


wrote:
2003

The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
& " INTO CHOOSERev" _
& Chr(10) & "FROM CHOOSEData" & Chr(10) _
& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.

I guess the syntax I am using is incorrect after the .Execute command. (Note the . INTO CHOOSERev
10th line

Any help greatly appreciated!

EagleOne

  #10  
Old August 10th, 2008, 06:22 PM posted to microsoft.public.access
[email protected]
external usenet poster
 
Posts: 87
Default SQL code works in Access SQL window but not in VBA SQL code

On Aug 10, 10:01*am, wrote:
Louis,

I made all of your suggested changes and I still get the same error.

A Da! epiphany may have occured in my mind.

I bet that a table is a RecordSet in a Project? No?

If so,

Set CHOOSEDRev = dbs.OpenRecordset("SELECT * FROM CHOOSEDATA Where (((CHOOSEData.TRAN_TYPE) In
('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'))") * * * * * *'may be a solution?

To be more clear:

The VBA module is in "Tools.mdb"

So I am in Tools.mdb and have set currentdb to "Recon.mdb"

In Recon.mdb I have previously created a table "ChooseData"

I want to use "ChooseData" to create a new "ChooseRev" table in Recon.mdb

Then I close Recon.mdb and stay in "Tools.mdb" to create another Recon.mdb as Recon2.mdb.



wrote:
On Aug 10, 9:01*am, wrote:
Bottom line, I am attempting to create, in "dbs" project, a new table CHOOSERev from CHOOSEData


wrote:
2003


The following code works in the Access Query SQL-view window but when I try to run it in VBA, it
produces the following error (#3601):
* *"Too few parameters. Expected 1"


dbs.Execute "SELECT CHOOSEData.BFY, CHOOSEData.APPN_SYMB, " _
* *& "CHOOSEData.SBHD, CHOOSEData.BCN, CHOOSEData.SA_SX, CHOOSEData.AAA_UIC, " _
* *& "CHOOSEData.ACRN, CHOOSEData.AMT, CHOOSEData.DOC_NUMBER, " _
* *& "CHOOSEData.FIPC, CHOOSEData.REG_NUMB, CHOOSEData.TRAN_TYPE, " _
* *& "CHOOSEData.DOV_NUM, CHOOSEData.PAA, CHOOSEData.COST_CODE, " _
* *& "CHOOSEData.OBJ_CODE, CHOOSEData.EFY, CHOOSEData.REG_MO, " _
* *& "CHOOSEData.RPT_MO, CHOOSEData.EFFEC_DATE, CHOOSEData.Orig_Sort, " _
* *& "CHOOSEData.LTrim_BFY, CHOOSEData.LTrim_AAA, CHOOSEData.LTrim_REG, " _
* *& "CHOOSEData.LTrim_DOV, CHOOSEData.AMT_Rev, CHOOSEData.CONCACT" _
* *& " INTO CHOOSERev" _
* *& Chr(10) & "FROM CHOOSEData" & Chr(10) *_
* *& " WHERE (((CHOOSEData.TRAN_TYPE) In ('1K','2D')) And ((CHOOSEData.LTrim_REG)'7'));"


I copied the Access query which works! exactly from the SQL window (Except I had to parse the lines
with &, " etc.


I guess the syntax I am using is incorrect after the .Execute command.. *(Note the . INTO CHOOSERev
10th line


Any help greatly appreciated!


EagleOne- Hide quoted text -


- Show quoted text -


Sometimes Access gives strange error messages.


I would look at the following:


* *--There is no space after " INTO CHOOSERev".
* *--There is a line-feed character before and after "FROM CHOOSEData".
* *--There is a semi-colon embedded in the sql string.
* *--There is a limit to the length of an sql statement and you are
wasting
* * *part of that limited number of characters by repeating
"CHOOSEDATA.".
* * *( I think the limit is 255 characters )- Hide quoted text -


- Show quoted text -



OK. I remember. You want to copy a table from one database to
another. You were given several suggestions as how to do this.

You were not given the menu-driven suggestion:

Open the receiving database. From the File Menu, choose Get
External data. A dialog box will open. You want to import data from
the sending database. Navigate in the file find dialog box until you
see the originating database. Select it. See the table names in the
database. Choose CHOOSEData. Click OK.

CHOOSEDATA will appear in the receiving database if none had existed
before. If a CHOOSEDATA exists, the table will appear named
CHOOSEDATA1.

In the Database Tables menu, highlight the "CHOOSEDATA" table and
right mouse click. You will be allowed to rename the table to
CHOOSERev.

I am surprised the Execute method failed.

The other option I can think of is to use the: DoCmd.RunSql sqlStmt

But really, I think you are working too hard to copy a table from one
MDB to another.

 




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 01:43 AM.


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