Selasa, 24 Mei 2011

[MS_AccessPros] Add Dynamic Column name

 

Hello,

I am trying to add the column name dynamically using VBA,
This is the code snippet that I am trying to use,

Private Sub Detail_Click()
Dim Q1 As Integer
Dim colName As String

Q1 = Me![SubformEventDetails].Form![Quantity]
colName = Me![SubformEventDetails].Form![Item_Name]
DoCmd.RunSQL " INSERT INTO Tbl_InvDetails ('" & colName & "') values ( " & Q1 & " ) "

End Sub

I get the following error
The INSERT INTO statement contains the following unknown field name: "6ft_Table". Make sure you typed the name correctly, and try the operation again.

However, DoCmd.RunSQL " INSERT INTO Tbl_InvDetails (6ft_Table) values ( " & Q1 & " ) " works perfectly fine.

Thanks,

Jim Wagner

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar