for loop question

E

ernestb08

In the following code I want for 'x' to be read as a variable (change
dynamically) in the sql statements, but it reads it as a character.

by the time the loop runs for the second it tells me that table x has
already been created.

I want for 'x' inside the sql statement to incremently change by 1
every time the loop runs. the FOR loop syntax is o.k., but maybe the
reason why it doesn't work is because everything is in parenthesis. I
need to let the interpreter know that 'x' inside the parenthesis is a
variable not a character.

Any ideas?


'X' will eventually be arund 4132.

Dim x As Integer
Dim i As Integer

'i = 5
'For x = 3 To i Step 1
Dim strSQL01 As String

strSQL01 = " CREATE TABLE x ( OBJECTID number not null,uniqueID number,
Point_X Number, Point_Y Number);"
CurrentDb.Execute strSQL01
Dim strSQL02 As String

strSQL02 = " INSERT INTO x SELECT OBJECTID, uniqueID, Point_X, Point_Y
FROM Vertices WHERE ((([Vertices].[UniqueID]) = 01)) ORDER BY
[Vertices].[UniqueID], [Vertices].[OBJECTID];"
CurrentDb.Execute strSQL02
'Next x
 
N

Norman Yuan

i = 5
For x = 3 To i Step 1
Dim strSQL01 As String

strSQL01 = " CREATE TABLE " & x & " ( OBJECTID number not null,uniqueID
number,
Point_X Number, Point_Y Number);"
CurrentDb.Execute strSQL01
Dim strSQL02 As String

strSQL02 = " INSERT INTO " & x & " SELECT OBJECTID, uniqueID, Point_X,
Point_Y
FROM Vertices WHERE ((([Vertices].[UniqueID]) = 01)) ORDER BY
[Vertices].[UniqueID], [Vertices].[OBJECTID];"
CurrentDb.Execute strSQL02
Next x
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top