I truly do *NOT* think you are getting a Type Mismatch error from the code you think it is coming from.
Because of the way you are checking for Err.Number, you don't *KNOW* that the error occurred on the statement just before that check!!!
If you do
just before attempting a statement, *THEN* you will be able to be sure whether or not the error is really on that line.
But the real problem is the indiscriminate way you are using ON ERROR RESUME NEXT.
In my opinion, you should *NEVER* use it at the top of a page or function and then just leave it turned on.
Instead, you should turn it on and off (turn off via ON ERROR GOTO 0), leaving it on *ONLY* for statements where you really expect that an error is (a) likely and (b) a spot where you can actually do something *ABOUT* the error.
So I would perhaps have written that part of the code thus:
'Check that the root directory is found
if folder = false then
response.write "Error: Upload stopped, root directory not found, ensure storage device is still plugged in!"
On Error GoTo 0
'Move the files in the root first
for each item in folder.files
tmpjpg = item.name
'File moved, add to database
sql="'" & tmpjpg
sql=sql & "'," & upnum
sql=sql & ",0,"&datetime
sql=sql & ","&modified
'Add to database
handle = add_to_database("images","jpg,img_set,sold,upload_date_time,taken",sql)
if handle = true then
response.write "Error: Upload stopped (1), error adding to database: " & handle & "<br />"
response.end ' DEFINITELY do NOT keep going after such an error!
ON ERROR RESUME NEXT
'Move the file if it has been added to the database
fs.MoveFile folder&"\"&tmpjpg, whereto
if err.number <> 0 then
response.write "Error: Upload stopped (2), error code: "&err.description&" | "&folder&"\"&tmpjpg & "<br />"
ON ERROR GOTO 0