F
Fred's
Hi Folks,
I've built a form with 3 botton control which the first two bottom
open 2 table and third bottom execute "Archive"
Execute the sql statement which you can find the full statement
below.
My problem is that when I am pressing the "Archive" button, I 'm
getting this error "Run-time error "13": Type mismatch" which goes to
THIS:
Err_Execute:
' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
Can someone could help me to fix this error
Thank you in advance
Fred's
Here is MY full Sql statement:
Private Sub ViewArchive_Click()
Dim strSQLAppend As String
Dim strSQLDelete As String
Dim errLoop As Error
Dim dteExpiry As Date
dteExpiry = DateAdd("yyyy", -2, Date)
' Define two SQL statements for action queries.
strSQLAppend = "INSERT INTO NCtblExpired " & _
"( scarID, scarNumber, supplierName, retekNumber,
problemDate, season, division, orderNumber, country, style, color1,
color2, color3, color4, problemCode1, problemCode2, problemCode3,
problemCode4, problemCode5, problemCode5, problemCode6,
problemDescription, impact, correctiveAction, preventiveAction,
reworkManhours, hourlyRates, laborCost, disposition,
reworkInstructions, &_ sppCoordinator, rootCause, supplierResponse,
responseCode, responseDate, resp_Code, reviewedby, reviewDate,
followUpHistory, status, generateScar, sentToSuppliers, closedDate, "
& _
"merchType, verificationDate, verifiedBy ) " & _
"SELECT ncTbl.scarID, " & _
"ncTbl.scarNumber, ncTbl.supplierName,
ncTbl.retekNumber, ncTbl.problemDate, ncTbl.season, ncTbl.division,
ncTbl.orderNumber, ncTbl.country, ncTbl.style, ncTbl.color1, "
strSQLAppend = strSQLAppend & "ncTbl.color2" & _
"ncTbl.color2, ncTbl.color3, ncTbl.color4,
ncTbl.problemCode1, ncTbl.problemCode2, ncTbl.problemCode3,
ncTbl.problemCode4, ncTbl.problemCode5, ncTbl.problemCode6,
ncTbl.problemDescription, " & _
strSQLAppend = strSQLAppend & "ncTbl.impact" & _
"ncTbl.impact, ncTbl.correctiveAction,
ncTbl.preventiveAction, ncTbl.reworkManhours, ncTbl.hourlyRates,
ncTbl.laborCost, ncTbl.disposition, ncTbl.reworkInstructions,
ncTbl.sppCoordinator, ncTbl.rootCause " & _
strSQLAppend = strSQLAppend & "ncTbl.supplierResponse" & _
"ncTbl.supplierResponse, ncTbl.responseCode, ncTbl.responseDate,
ncTbl.resp_Code, ncTbl.reviewedby, ncTbl.reviewDate,
ncTbl.followUpHistory, ncTbl.status, ncTbl.generateScar,
ncTbl.sentToSuppliers, ncTbl.closedDate, ncTbl.merchType,
ncTbl.verificationDate, ncTbl.verifiedBy, " & _
"FROM ncTbl " & _
"WHERE ncTbl.problemDate <= #" & dteExpiry & "#;"
strSQLDelete = "DELETE ncTbl.scarID, " & _
"ncTbl.scarNumber, ncTbl.supplierName, ncTbl.retekNumber,
ncTbl.problemDate, ncTbl.season, " & _
"ncTbl.division, ncTbl.orderNumber, ncTbl.country,
ncTbl.style, ncTbl.color1, ncTbl.color2, " & _
"ncTbl.color3, ncTbl.color4, ncTbl.problemCode1,
ncTbl.problemCode2, ncTbl.problemCode3, " & _
"ncTbl.problemCode4, ncTbl.problemCode5,
ncTbl.problemCode6, ncTbl.problemDescription, " & _
"ncTbl.impact, ncTbl.correctiveAction,
ncTbl.preventiveAction, ncTbl.reworkManhours, " & _
"ncTbl.hourlyRates, ncTbl.laborCost, ncTbl.disposition,
ncTbl.reworkInstructions, " & _
"ncTbl.sppCoordinator, ncTbl.rootCause, ncTbl.supplierResponse,
ncTbl.responseCode, " & _
"ncTbl.responseDate, ncTbl.resp_Code, ncTbl.reviewedby,
ncTbl.reviewDate, ncTbl.followUpHistory, " & _
"ncTbl.status, ncTbl.generateScar, ncTbl.sentToSuppliers,
ncTbl.closedDate, ncTbl.merchType, " & _
"ncTbl.verificationDate, ncTbl.verifiedBy, " & _
"FROM ncTbl " & _
"WHERE ncTbl.problemDate <= #" & dteExpiry & "#;"
' Run action query to restore data. Trap for errors,
' checking the Errors collection if necessary.
On Error GoTo Err_Execute
CurrentDb.Execute strSQLAppend, dbFailOnError
CurrentDb.Execute strSQLDelete, dbFailOnError
On Error GoTo 0
Exit Sub
Err_Execute:
' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
End Sub
I've built a form with 3 botton control which the first two bottom
open 2 table and third bottom execute "Archive"
Execute the sql statement which you can find the full statement
below.
My problem is that when I am pressing the "Archive" button, I 'm
getting this error "Run-time error "13": Type mismatch" which goes to
THIS:
Err_Execute:
' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
Can someone could help me to fix this error
Thank you in advance
Fred's
Here is MY full Sql statement:
Private Sub ViewArchive_Click()
Dim strSQLAppend As String
Dim strSQLDelete As String
Dim errLoop As Error
Dim dteExpiry As Date
dteExpiry = DateAdd("yyyy", -2, Date)
' Define two SQL statements for action queries.
strSQLAppend = "INSERT INTO NCtblExpired " & _
"( scarID, scarNumber, supplierName, retekNumber,
problemDate, season, division, orderNumber, country, style, color1,
color2, color3, color4, problemCode1, problemCode2, problemCode3,
problemCode4, problemCode5, problemCode5, problemCode6,
problemDescription, impact, correctiveAction, preventiveAction,
reworkManhours, hourlyRates, laborCost, disposition,
reworkInstructions, &_ sppCoordinator, rootCause, supplierResponse,
responseCode, responseDate, resp_Code, reviewedby, reviewDate,
followUpHistory, status, generateScar, sentToSuppliers, closedDate, "
& _
"merchType, verificationDate, verifiedBy ) " & _
"SELECT ncTbl.scarID, " & _
"ncTbl.scarNumber, ncTbl.supplierName,
ncTbl.retekNumber, ncTbl.problemDate, ncTbl.season, ncTbl.division,
ncTbl.orderNumber, ncTbl.country, ncTbl.style, ncTbl.color1, "
strSQLAppend = strSQLAppend & "ncTbl.color2" & _
"ncTbl.color2, ncTbl.color3, ncTbl.color4,
ncTbl.problemCode1, ncTbl.problemCode2, ncTbl.problemCode3,
ncTbl.problemCode4, ncTbl.problemCode5, ncTbl.problemCode6,
ncTbl.problemDescription, " & _
strSQLAppend = strSQLAppend & "ncTbl.impact" & _
"ncTbl.impact, ncTbl.correctiveAction,
ncTbl.preventiveAction, ncTbl.reworkManhours, ncTbl.hourlyRates,
ncTbl.laborCost, ncTbl.disposition, ncTbl.reworkInstructions,
ncTbl.sppCoordinator, ncTbl.rootCause " & _
strSQLAppend = strSQLAppend & "ncTbl.supplierResponse" & _
"ncTbl.supplierResponse, ncTbl.responseCode, ncTbl.responseDate,
ncTbl.resp_Code, ncTbl.reviewedby, ncTbl.reviewDate,
ncTbl.followUpHistory, ncTbl.status, ncTbl.generateScar,
ncTbl.sentToSuppliers, ncTbl.closedDate, ncTbl.merchType,
ncTbl.verificationDate, ncTbl.verifiedBy, " & _
"FROM ncTbl " & _
"WHERE ncTbl.problemDate <= #" & dteExpiry & "#;"
strSQLDelete = "DELETE ncTbl.scarID, " & _
"ncTbl.scarNumber, ncTbl.supplierName, ncTbl.retekNumber,
ncTbl.problemDate, ncTbl.season, " & _
"ncTbl.division, ncTbl.orderNumber, ncTbl.country,
ncTbl.style, ncTbl.color1, ncTbl.color2, " & _
"ncTbl.color3, ncTbl.color4, ncTbl.problemCode1,
ncTbl.problemCode2, ncTbl.problemCode3, " & _
"ncTbl.problemCode4, ncTbl.problemCode5,
ncTbl.problemCode6, ncTbl.problemDescription, " & _
"ncTbl.impact, ncTbl.correctiveAction,
ncTbl.preventiveAction, ncTbl.reworkManhours, " & _
"ncTbl.hourlyRates, ncTbl.laborCost, ncTbl.disposition,
ncTbl.reworkInstructions, " & _
"ncTbl.sppCoordinator, ncTbl.rootCause, ncTbl.supplierResponse,
ncTbl.responseCode, " & _
"ncTbl.responseDate, ncTbl.resp_Code, ncTbl.reviewedby,
ncTbl.reviewDate, ncTbl.followUpHistory, " & _
"ncTbl.status, ncTbl.generateScar, ncTbl.sentToSuppliers,
ncTbl.closedDate, ncTbl.merchType, " & _
"ncTbl.verificationDate, ncTbl.verifiedBy, " & _
"FROM ncTbl " & _
"WHERE ncTbl.problemDate <= #" & dteExpiry & "#;"
' Run action query to restore data. Trap for errors,
' checking the Errors collection if necessary.
On Error GoTo Err_Execute
CurrentDb.Execute strSQLAppend, dbFailOnError
CurrentDb.Execute strSQLDelete, dbFailOnError
On Error GoTo 0
Exit Sub
Err_Execute:
' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
End Sub