Run Time Error 3464 While Executing An Append Query

  • Thread starter John O. Graybill
  • Start date
J

John O. Graybill

Greetings All:

Can anyone suggest why this function fails with runtime Error 3464
"Data type mismatch in criteria expression"? The value of
varTaskKeyID is always an AutoNumber Long Integer from another table.
Am I not seeing something in the syntax of the WHERE clause? Any help
would be most appreciated. Thanks,

John

Function fcnRunAppender(varTaskKeyID As Variant)

On Error GoTo Err_fcnRunAppender
Dim strINSERT As String
Dim strSELECT As String
Dim strFROM As String
Dim strWHERE As String
Dim strSQL As String
Dim DB As Database

If IsNull(varTaskKeyID) = True Then
GoTo Exit_fcnRunAppender
End If

Set DB = CurrentDb

strINSERT = "INSERT INTO [tblOldStrengthTaskRecords]"
strSELECT = "SELECT tblStrengthTasks.*"
strFROM = "FROM [tblStrengthTasks]"
strWHERE = "WHERE (((tblStrengthTasks.StrengthTaskKeyID)= " &
varTaskKeyID & "));"
strSQL = strINSERT & strSELECT & strFROM & strWHERE

DB.Execute strSQL, dbFailOnError

Exit_fcnRunAppender:
Exit Function

Err_fcnRunAppender:
Call ErrorLogger(Me.Name, "fcnRunAppender_Function",
Err.Description, Err.Number)
Resume Exit_fcnRunAppender

End Function
 
O

Ofer

Are you sure that the structure of both table: tblOldStrengthTaskRecords and
tblStrengthTasks is the same, all the field type are the same.
If so
Why the parameter you sending is Variable and not long, if your problem is
the null then check before you runing the function.
 
J

John O. Graybill

Thanks Ofer.

I have checked and double-checked and am sure the table structures are
the same except for the first field. In the tblStrengthTasks table the
first field is an AutoNumber Long Integer and the corresponding field
in the tblOldStrengthTaskRecords table is simply a Long Integer. This
is the only difference between the two tables.

I probably could use a Long Integer data type instead of a Variant for
the argument, but I check for Null at the very beginning of the
procedure and exit the sub if it is Null.

Thank you for your thoughts.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top