Can anyone tell me if the RunSQL command has a limit?
I have created a process to add a number of columns to a table, with each row of each table having an entry of '1234567980'.
The process works when I set the rows to 183. But when I set this to 184, the process doesn't load the data into the columns. I get no error at all, just no entries in my rows.
I have no idea why this works for <= 183, but not for >183. Any experts out there who can tell me why?
Here's the code:
Private Sub Test_db_entries()
Dim sTest1 As String
Dim sTest2 As String
Dim i As Integer
Dim sText1(9999)
Dim sText2(9999)
'Imax = 184 - this doesn't work
iMax = 183 '- this does work
'CREATE TESTTAB TABLE
strSQL = "CREATE TABLE TestTab ([Fld1] TEXT(10));"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
'ADD MORE COLUMNS
For i = 2 To iMax
sText1(i) = "Fld" & i
DoCmd.RunSQL "ALTER TABLE TestTab ADD COLUMN [" & sText1(i) & "] TEXT(10);"
Next i
'POPULATE DATA
For i = 1 To iMax
If i = 1 Then
sText1(1) = "Fld1"
sText2(1) = "1234567890"
sTest1 = "[" & sText1(1) & "]"
sTest2 = "'" & sText2(1) & "'"
Else
sText1(i) = "Fld" & i
sText2(i) = "1234567890"
sTest1 = sTest1 & ", [" & sText1(i) & "]"
sTest2 = sTest2 & ", '" & sText2(i) & "'"
End If
Next i
DoCmd.RunSQL "INSERT INTO TestTab(" & sTest1 & ") VALUES(" & sTest2 & ");"
End Sub
I have created a process to add a number of columns to a table, with each row of each table having an entry of '1234567980'.
The process works when I set the rows to 183. But when I set this to 184, the process doesn't load the data into the columns. I get no error at all, just no entries in my rows.
I have no idea why this works for <= 183, but not for >183. Any experts out there who can tell me why?
Here's the code:
Private Sub Test_db_entries()
Dim sTest1 As String
Dim sTest2 As String
Dim i As Integer
Dim sText1(9999)
Dim sText2(9999)
'Imax = 184 - this doesn't work
iMax = 183 '- this does work
'CREATE TESTTAB TABLE
strSQL = "CREATE TABLE TestTab ([Fld1] TEXT(10));"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
'ADD MORE COLUMNS
For i = 2 To iMax
sText1(i) = "Fld" & i
DoCmd.RunSQL "ALTER TABLE TestTab ADD COLUMN [" & sText1(i) & "] TEXT(10);"
Next i
'POPULATE DATA
For i = 1 To iMax
If i = 1 Then
sText1(1) = "Fld1"
sText2(1) = "1234567890"
sTest1 = "[" & sText1(1) & "]"
sTest2 = "'" & sText2(1) & "'"
Else
sText1(i) = "Fld" & i
sText2(i) = "1234567890"
sTest1 = sTest1 & ", [" & sText1(i) & "]"
sTest2 = sTest2 & ", '" & sText2(i) & "'"
End If
Next i
DoCmd.RunSQL "INSERT INTO TestTab(" & sTest1 & ") VALUES(" & sTest2 & ");"
End Sub