Adding a record to a table

J

JimP

How can I write a SQL statement that adds a record to a table?

e.g.

Table = MyTable
First Column = ColumnA (set to "MyValueA")
Second Column ColumnB (set to "MyValueB")
 
K

Ken Snell

Are you wanting to run the append query from VBA? Assuming yes, and that the
variables are numeric, herie is how you'd build the SQL statement that you
then would run:

Dim strSQL As String
strSQL = "INSERT INTO MyTable " & _
"(ColumnA, ColumnB) " & _
"VALUES (" & MyValueA & ", " & _
MyValueB & ");"


If the variables are text:

Dim strSQL As String
strSQL = "INSERT INTO MyTable " & _
"(ColumnA, ColumnB) " & _
"VALUES (""" & MyValueA & """, """ & _
MyValueB & """);"

--

Ken Snell
http://www.accessmvp.com/KDSnell/
 
Top