John Nelson
Registered User.
- Local time
- Today, 14:45
- Joined
- Jan 26, 2005
- Messages
- 16
I'm having trouble with the INSERT INTO statement. I can't figure out why I'm getting a syntax error. Any ideas?
The debugger is grabbing the cnn.Execute strSQL line.
Here's the whole procedure in case it's someting other than the SQL stuff.
Thanks!
Code:
strSQL = "INSERT INTO tblTransactions ( PartID, ProjectID, TransDate, Qty, TotalPrice ) "
strSQL = strSQL & "SELECT" & intPartID & ", " & intProjID & ", " & datDate & ", "
strSQL = strSQL & intQty & ", " & varTotPrice
cnn.Execute strSQL
The debugger is grabbing the cnn.Execute strSQL line.
Here's the whole procedure in case it's someting other than the SQL stuff.
Thanks!
Code:
Private Sub cmdEnterTrans_Click()
Dim intPartID As Integer, intQty As Integer, intProjID As Integer
Dim datDate As Date, varPrice As Variant, varTotPrice As Variant
Dim strSQL As String
Dim cnn As ADODB.Connection, rst As ADODB.Recordset
Set cnn = CurrentProject.Connection
cnn.BeginTrans
If IsNull(Me!PARTNO) Then
MsgBox "Please enter a part number before continuing."
Me!PARTNO.SetFocus
Exit Sub
End If
If IsNull(Me!txtQty) Or IsNull(Me!txtDate) Then
MsgBox "Please fill out the transaction form completely before continuing."
Me!Qty.SetFocus
Exit Sub
End If
intPartID = Me!PartID
intProjID = Me!cboProj.Column(1)
datDate = Me!txtDate
intQty = Me!txtQty
varPrice = DLookup("PRICE", "tblParts", [PartID] = "intPartID")
varTotPrice = intQty * varPrice
strSQL = "INSERT INTO tblTransactions ( PartID, ProjectID, TransDate, Qty, TotalPrice ) "
strSQL = strSQL & "SELECT" & intPartID & ", " & intProjID & ", " & datDate & ", "
strSQL = strSQL & intQty & ", " & varTotPrice
cnn.Execute strSQL
cnn.CommitTrans
End Sub