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!

Help with Insert Statement

Status
Not open for further replies.

jfarrell

Technical User
Mar 3, 2001
15
US
If anyone can help me I would appreciate it.
I have a VB form connected to an Access97 table via ADO.
The ADO object is adoSchool. I would like to insert
records but I get error codes. My code looks like this!
Private Sub cmdInsert_Click()
Dim objComm As ADODB.Command
Set objComm = New ADODB.Command
objComm.ActiveConnection = objConn
objComm.CommandText = "INSERT INTO School _ (Schoolid,Name,Principal,Telephone) " & _
"VALUES('100','NewSchool','Principal','N/A')"
objComm.CommandText = adCmdText
objConn.Execute
adoSchool.Recordset.Resync adAffectCurrent, adResyncAllValues
End Sub
I'm getting 'Argument not optional' error codes on the line
objConn.Execute
Can anyone give me suggestions on what is wrong. Thankyou.
John
 
it is better this way:

objconn.execute "INSERT INTO School _ (Schoolid,Name,Principal,Telephone) " & _
"VALUES('100','NewSchool','Principal','N/A')"

i'll use the command object if i need to use parameters.

arcanist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top