Results 1 to 2 of 2

Thread: Type Mismatch

  1. #1
    Join Date
    Mar 2004
    Posts
    139

    Unanswered: Type Mismatch

    I'm getting a 'type mismatch' error with this project-

    I tried changing the recordset declaration to ADO.Recordset, that didn't help. When I choose debug it's highlighting the Set rst line.

    Does anyone have any recommendations?

    Private Sub Write_Credit_AfterUpdate()

    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"

    End Sub
    Thanks,
    Bill

  2. #2
    Join Date
    Jul 2004
    Posts
    125
    IS Me!TTNUM a string? If it is you must enclose it in quotes. Also, there is an error in the syntax:

    (dbo_CREDITS_DETAIL.TTNUM = " & Me!TTNUM & ")"

    if it's a number, it should be
    (((dbo_CREDITS_DETAIL.TTNUM) = " & Me!TTNUM & "))"

    if it's a string, it should be:

    (((dbo_CREDITS_DETAIL.TTNUM) = " & chr(34) & Me!TTNUM & chr(34) & "))"

    I hope this helps.
    (Using Chr(34) will sure to start a new discussion)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •