Hello,
I have spent the whole day trying to figure this out and I am not having any luck! Any help you provide will be GREATLY APPRECIATED. Ok the problem is quite simple, I am trying to insert 340 records automatically, so here is my code:
Public Sub insert_row_sub()
DoCmd.SetWarnings False
Dim num As Long
Dim sql As String
sql = "INSERT INTO new_tbl(code,s_id,fee_class) VALUES " & "(" & num & ",688,'Expensive');"
For num = 92259 To 92599
num = num + 1
DoCmd.RunSQL (sql)
'Print to immediate window
Debug.Print sql
'Halt execution for testing purposes
Stop
DoCmd.RunSQL sql
Next num
DoCmd.SetWarnings True
End Sub
And this is what prints in my immediate window:
INSERT INTO new_tbl(code,s_id,fee_class) VALUES (0,688,'Expensive');
instead of entering records with code column= 92259 To 92599
I get 340 records all with code column=0.
What am I doing wrong?
Thanks,
Judy
I have spent the whole day trying to figure this out and I am not having any luck! Any help you provide will be GREATLY APPRECIATED. Ok the problem is quite simple, I am trying to insert 340 records automatically, so here is my code:
Public Sub insert_row_sub()
DoCmd.SetWarnings False
Dim num As Long
Dim sql As String
sql = "INSERT INTO new_tbl(code,s_id,fee_class) VALUES " & "(" & num & ",688,'Expensive');"
For num = 92259 To 92599
num = num + 1
DoCmd.RunSQL (sql)
'Print to immediate window
Debug.Print sql
'Halt execution for testing purposes
Stop
DoCmd.RunSQL sql
Next num
DoCmd.SetWarnings True
End Sub
And this is what prints in my immediate window:
INSERT INTO new_tbl(code,s_id,fee_class) VALUES (0,688,'Expensive');
instead of entering records with code column= 92259 To 92599
I get 340 records all with code column=0.
What am I doing wrong?
Thanks,
Judy