Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Type Mismatch Error (2002)

    Can anyone tell what is wrong with the following function? When I try to run it, I get a type mismatch error but nothing is highlighted to let me know what is mismatched. The fields I am using are text fields and I have set them as string variables.
    I am trying to send an email to every email address located in the query qryContacts. I used a copy of code that works fine in another database in which I am emailing an attachment to every email address in a query.


    Public strLocCode As String

    Public Function EmailEval()
    Dim dbs As DAO.Database
    Dim rst As DAO.Recordset

    On Error GoTo ErrHandler

    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("qryContacts", dbOpenDynaset)

    Do While rst.EOF = False
    strLocCode = rst!LocCode
    DoCmd.SendObject acSendNoObject, , , _
    rst!MgrEMail, , , rst!Loc & " Evaluation File", _
    "Open My Computer and open the eval file located " & _
    "at N:EvaluationEval.mdb", False

    rst.MoveNext
    Loop

    ExitHandler:
    On Error Resume Next
    strLocCode = Null
    rst.Close
    Set rst = Nothing
    Set dbs = Nothing
    Exit Function

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Function
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Type Mismatch Error (2002)

    Temporarily make the line

    On Error GoTo ErrHandler

    into a comment by inserting an apostrophe ' in front of it. When you run the code, the offending line will be highlighted (this was prevented by the error handler).

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Type Mismatch Error (2002)

    Thanks. Thats a great idea to help find the problem. When I copied the code I had not changed the name of one of the variables in the ErrHandler.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Type Mismatch Error (2002)

    I take it that the problem was with the line <code>strLocCode = Null</code>?

    Don't forget to uncomment the line that sets the error handler once the problem has been solved!

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Type Mismatch Error (2002)

    Is it possible with DoCmd.SendObject code to send a file such as an access database as an email attachment? I didn't see in the list for acObjectType where I could make that selection?
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Type Mismatch Error (2002)

    No, DoCmd.SendObject can only be used to send an object within the current database, such as a table or query, not to send a database as a whole, or any other file. If you use Outlook, you could use Automation, but sending a .mdb file is complicated - the default settings won't allow the recipient to get an .mdb attachment, so you'd have to create a zip file from the database, and attach that. And sending the current database is not possible because the file is in use.

  7. #7
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Type Mismatch Error (2002)

    Thanks for the reply. I'll go back to my first idea which is to have a batch file copy each database to the location I want and then just instruct them to open it.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

Posting Permissions

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