Type Mismatch error

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

In Access 2002, I'm getting a type mismatch error in the
following project:

I changed the 2nd variable declaration to ADO.Recordset
on a tip that was provided, but I'm still getting the
error. Does anyone have any advice.

Dim db As Database
Dim rst As Recordset
Dim strSQL As String

strSQL = " SELECT dbo_CREDITS_DETAIL.Full_Item,
dbo_CREDITS_DETAIL.Price, dbo_CREDITS_DETAIL.QTY" & _
" FROM dbo_CREDITS_DETAIL" & _
" WHERE (((dbo_CREDITS_DETAIL.TTNUM) = " & Me!
TTNUM & "))"

Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)

DoCmd.TransferText acExportDelim, ,
strSQL, "H:\Text_Files\test2.txt"
 
Hi Bill, you should declare both DAO variables as such.
Dim db As DAO.Database
Dim rst AS DAO.Recorset

However, why are you using them at all?
The DoCmd.TransferText statement doesn't require these objects!
Try the code without DAO objects.

Also, ensure that Me!TTNUM is the correct datatype for the query. And, if
it's text, wrap it in quotes.

Hope this helps, Graeme.
 
Back
Top