Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Rows using Cmd object

Status
Not open for further replies.

Stretchy

Programmer
Mar 26, 2002
87
GB
I am trying to do this as the previous attempt with recordsets failed. Here is my code. It is from the submit button on an Access form. The user enters data into the required fields and hits submit which should update the table.
--------------------------------
Private Sub Add_Click()
Dim cmd As ADODB.Command
Dim strSQL As String

Set cmd = New ADODB.Command
strSQL = "INSERT INTO tbl_target (Date, Department, Division, Section, Target) VALUES (TarDate, Dept, Division, Section, AdTarget)"

Set cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = strSQL
cmd.Execute

End Sub
------------------------------

Thx for any help _______________
Stretchy
 
Presumably you are going from Access to SQL Server.

Can you let me know and I will provide the code to input the records across. If it is as I thought you are best to use parameters which are part of ADO.

Let me know and I will respond

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top