I'm been struggling with this SQL statement for several days.
I want to insert values from 2 tables into another.
I get a missing operator error on the WHERE statement
I want to insert values from 2 tables into another.
I get a missing operator error on the WHERE statement
Code:
Private Sub cmdInsertDefaultReviewers_Click()
Dim strSQL, strCN As String 'SQL statement.
Dim lngID As Long 'Primary key value of the new record.
Dim NewDate, NewDueDate As Date
lngID = Me.SerialNumber
strCN = Me.ContractorNumber
NewDate = Date
NewDueDate = DateAdd("d", 7, NewDate)
If Len(Me.DefaultReviewerType) > 0 Then
strSQL = "INSERT INTO tblSubmittalSuplementalReviewer ( SerialNumber , ContractorNumber, Reviewer)" & _
"SELECT " & lngID & " As SerialNumber , " & strCN & " As ContractorNumber, Reviewer " & _
"FROM tblSubmittalReviewList, tblSubmittalInfo " & _
"WHERE tblSubmittalReviewList.SerialNumber = " & lngID & " AND tblSubmittalReviewList.ContractorNumber = " & strCN & " AND tblSubmittalInfo.SubmitalType = " & Me.DefaultReviewerType & ";"
DBEngine(0)(0).Execute strSQL, dbFailOnError
Else
MsgBox "No Default Reviewer Selected."
End If
Me.frmSubmittalSupplementalReviewer.Requery
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, , "cmdDupe_Click"
Resume Exit_Handler
End Sub