K
krisjuchau
To give a little background, I have a form that initially inserts data
into table on submit. I have a second form that pulls from the table
and repopulates the form fields for editing purposes. I want to be
able to update the table on submit of this form. My query syntax seems
to be a little bit off, any help would be great. Here is the code:
Private Sub cmdSubmit_Click()
Dim strCustID, strCustName, strQ1, strQ2, strQ3, strQ4, strQ5 As
String
Dim strQ6, strQ7, strQ8, strQ9, strQ10, strQ11, strQ12 As String
Dim strQ13, strQ14, strType As String
Dim strInsertSQL, strCustComp As String
Dim intDate As Date
strCustID = Me.txtCustID.Value & ""
strCustName = Me.txtName.Value & ""
strQ1 = Me.txtQ1.Value & ""
strQ2 = Me.txtQ2.Value & ""
strQ3 = Me.txtQ3.Value & ""
strQ4 = Me.txtQ4.Value & ""
strQ5 = Me.txtQ5.Value & ""
strQ6 = Me.txtQ6.Value & ""
strQ7 = Me.txtQ7.Value & ""
strQ8 = Me.txtQ8.Value & ""
strQ9 = Me.txtQ9.Value & ""
strQ10 = Me.txtQ10.Value & ""
strQ11 = Me.txtQ11.Value & ""
strQ12 = Me.txtQ12.Value & ""
strQ13 = Me.txtQ13.Value & ""
strQ14 = Me.txtQ14.Value & ""
strType = Me.txtType.Value & ""
strDate = Me.txtDate.Value & ""
strCustComp = Me.txtCust.Value & ""
strInsertSQL = "UPDATE tblDevelop [CustName],[Q1S],[Q2S]," & _
"[Q3S],[Q4S],[Q5S],[Q6S],[Q7S],[Q8S], [Q9S],
[Q10S],
[Q11S], [Q12S], [Q13S], [Q14S]," & _
"[TYPE], [DATE], [CustComp]) " & _
"VALUES (" & Chr$(34) & strCustName & Chr$(34) & ",
" & Chr$(34) & strQ1 & Chr$(34) & ", " & Chr$(34) & strQ2 & Chr$(34)
&
", " & _
"'" & strQ3 & "', '" & strQ4 & "', '" & strQ5 & "',
'" & strQ6 & "', '" & strQ7 & "', " & _
"'" & strQ8 & "', '" & strQ9 & "', '" & strQ10 &
"',
'" & strQ11 & "', '" & strQ12 & "', '" & strQ13 & "', '" & strQ14 &
"', '" & strType & "', '" & strDate & " ', " & Chr$(34) & strCustComp
& Chr$(34) & ") WHERE tblDevelop.DevID = " & Me.txtDevID.Value
Call DoCmd.RunSQL(strInsertSQL)
MsgBox "Thank You"
End Sub
into table on submit. I have a second form that pulls from the table
and repopulates the form fields for editing purposes. I want to be
able to update the table on submit of this form. My query syntax seems
to be a little bit off, any help would be great. Here is the code:
Private Sub cmdSubmit_Click()
Dim strCustID, strCustName, strQ1, strQ2, strQ3, strQ4, strQ5 As
String
Dim strQ6, strQ7, strQ8, strQ9, strQ10, strQ11, strQ12 As String
Dim strQ13, strQ14, strType As String
Dim strInsertSQL, strCustComp As String
Dim intDate As Date
strCustID = Me.txtCustID.Value & ""
strCustName = Me.txtName.Value & ""
strQ1 = Me.txtQ1.Value & ""
strQ2 = Me.txtQ2.Value & ""
strQ3 = Me.txtQ3.Value & ""
strQ4 = Me.txtQ4.Value & ""
strQ5 = Me.txtQ5.Value & ""
strQ6 = Me.txtQ6.Value & ""
strQ7 = Me.txtQ7.Value & ""
strQ8 = Me.txtQ8.Value & ""
strQ9 = Me.txtQ9.Value & ""
strQ10 = Me.txtQ10.Value & ""
strQ11 = Me.txtQ11.Value & ""
strQ12 = Me.txtQ12.Value & ""
strQ13 = Me.txtQ13.Value & ""
strQ14 = Me.txtQ14.Value & ""
strType = Me.txtType.Value & ""
strDate = Me.txtDate.Value & ""
strCustComp = Me.txtCust.Value & ""
strInsertSQL = "UPDATE tblDevelop [CustName],[Q1S],[Q2S]," & _
"[Q3S],[Q4S],[Q5S],[Q6S],[Q7S],[Q8S], [Q9S],
[Q10S],
[Q11S], [Q12S], [Q13S], [Q14S]," & _
"[TYPE], [DATE], [CustComp]) " & _
"VALUES (" & Chr$(34) & strCustName & Chr$(34) & ",
" & Chr$(34) & strQ1 & Chr$(34) & ", " & Chr$(34) & strQ2 & Chr$(34)
&
", " & _
"'" & strQ3 & "', '" & strQ4 & "', '" & strQ5 & "',
'" & strQ6 & "', '" & strQ7 & "', " & _
"'" & strQ8 & "', '" & strQ9 & "', '" & strQ10 &
"',
'" & strQ11 & "', '" & strQ12 & "', '" & strQ13 & "', '" & strQ14 &
"', '" & strType & "', '" & strDate & " ', " & Chr$(34) & strCustComp
& Chr$(34) & ") WHERE tblDevelop.DevID = " & Me.txtDevID.Value
Call DoCmd.RunSQL(strInsertSQL)
MsgBox "Thank You"
End Sub