Do While Loop Issue

Ben_Entrew

Registered User.
Local time
Today, 14:37
Joined
Dec 3, 2013
Messages
177
Hi all,

I got a small problem here.
Somehow I wrote the wrong syntax it doesn't update my columns 12013 and
22013. These columns got number values.

Can someone help me please?

Thanks in advance guys.

Regards,
Ben

Code:
'Vorzeichen ändern

Public Sub TEST33()
Dim i As Integer
i = 1
Do While i < 3
DoCmd.RunSQL "UPDATE Orders SET [i2013] = [i2013] *2"

i = i + 1
Loop
End Sub
 
Concatenate:

"...SET [" & i & "2013] =..."
 
Hi,

I just played around with that Loop statement.

Somehow it doesn't add me columns if I use the similar syntax like before updating the column.

Regards,
Ben

Code:
Public Sub TEST33() 
Dim i As Integer 
i = 10
Do While i < 21 
DoCmd.RunSQL "ALTER Orders ADD COLUMN [" & i & "2013]" 

i = i + 1 
Loop 
End Sub
 
You're missing the word TABLE plus a data type for the field.
 
Thanks Paul,

for the quick reponse. It works.
I see I'm getting too tired.
I'll let it be for today...

Thanks again.

Bye.
 

Users who are viewing this thread

Back
Top Bottom