DruidAllanon
New member
- Local time
- Today, 07:01
- Joined
- Mar 1, 2011
- Messages
- 5
I'm having some trouble with an insert into SQL statement. For some reason, when I execute the code, it not only inserts a new record, but also changes a random record to match!!! It's really frustrating as none of my other codes have this problem.
Here's the background. I've got a table with the following fields:
TskID: AutoNumber
SubProjID: Number
ItemSqk: Number
SubSqk: Number
DocNum: Text
Description: Text
Here's my code:
Can someone please explain to me what is going on!?!?
Thanks in advance!
Mike
Here's the background. I've got a table with the following fields:
TskID: AutoNumber
SubProjID: Number
ItemSqk: Number
SubSqk: Number
DocNum: Text
Description: Text
Here's my code:
Code:
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
mySQL = "INSERT INTO tbl_TaskInfo ( SubProjID, ItemSqk, SubSqk, DocNum, Description)"
mySQL = mySQL & " VALUES (@SubPrjID, @ItmSqk, @SbSqk, @DocNm, @Desc)"
Dim objCommand As ADODB.Command
Set objCommand = New ADODB.Command
With objCommand
.ActiveConnection = cnn1
.CommandType = adCmdText
.CommandText = mySQL
.Prepared = True
.Parameters.Append .CreateParameter("SubPrjID", adBigInt, adParamInput, , SubProjID)
.Parameters.Append .CreateParameter("ItmSqk", adBigInt, adParamInput, , ItemSqk)
.Parameters.Append .CreateParameter("SbSqk", adBigInt, adParamInput, , SubSqk)
.Parameters.Append .CreateParameter("DocNm", adVarChar, adParamInput, 200, DocNum)
.Parameters.Append .CreateParameter("Desc", adVarChar, adParamInput, 200, Description)
.Execute , , adExecuteNoRecords
End With
Thanks in advance!
Mike