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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top