The following works fine
Public Sub MyAddColumn()
Dim TableToModify As String
Dim NewColName As String
Dim mylong As Long
TableToModify = "ABC"
NewColName = "NewCol20"
mylong = 1122
CurrentDb.Execute "ALTER TABLE " & TableToModify & " ADD COLUMN " & NewColName & " Long"
CurrentDb.Execute "UPDATE " & TableToModify & " SET " & NewColName & " = " & mylong
End Sub
But when I try and modify it to update with a string or text instead of a Long I get a Run-Time error 3061, Too few parameters. Expected 1. I've tried changing the ALTER TABLE to CHAR(14), Dim'ing the String with no size all with no luck.
Public Sub MyAddColumn()
Dim TableToModify As String
Dim NewColName As String
Dim myString As String * 14
TableToModify = "ABC"
NewColName = "NewCol20"
myString = "ABCD1234567890
CurrentDb.Execute "ALTER TABLE " & TableToModify & " ADD COLUMN " & NewColName & " TEXT(14)"
CurrentDb.Execute "UPDATE " & TableToModify & " SET " & NewColName & " = " & myString
End Sub
Any help appreciated.
Thanks
Sean
Tidak ada komentar:
Posting Komentar