Results 1 to 14 of 14
  1. #1
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566

    Rn-Time Error 13

    Hi Everyone

    I have set a breakpoint on Line 30 and then doing F8 to step through each line



    When I press F8 it gives me this error:-

    Click image for larger version. 

Name:	Error.JPG 
Views:	17 
Size:	84.9 KB 
ID:	46021

    When I hit Debug it highlights Line 90

    Can anyone see what is wrong with this ?

    Any help appreciated.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    You have db declared as a Recordset object, not a Database object.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    Mike, how many times have you had a Type Mismatch error?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi June

    Many thanks that fixes that specific one
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi Gasman

    I have lost count.

    If like me you don't understand the intricacies of VBA then I always fail on these types of error.

    Hence the number of posts.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    Quote Originally Posted by mike60smart View Post
    Hi Gasman

    I have lost count.

    If like me you don't understand the intricacies of VBA then I always fail on these types of error.

    Hence the number of posts.
    So if I asked you to give me a set amount of money, and you gave me that amount requested less one pound each time, and did it every time I asked you for a certain amount, you would not realise your error and where you are going wrong?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Well I wouldn't give you the money to start with unless you had carried out work which needs a payment.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    What I am trying to get at, is to learn from your mistakes, not just repeat them, time after time, after time.
    The amount example was just that, an example of just doing the same error, time after time, with no thought on how to fix it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Mike, do you make it a habit to research the error, or at least click on the Help button and see what the message means, or do you just post in a forum?
    Posting here, you are likely to get a solution but not learn much. Delving into the meaning of the message will probably help you next time it arises.

    I usually try to lead or teach (OK, maybe not EVERY time) rather than just solve, which is why my posts are usually longer than average which often causes me to be late to the party so to speak. Don't get me wrong, I know that some people have cognitive disabilities (not saying you do) and I respect that and try to allow for it. I'm saying that if you have to click Help 10x before it sinks in, that's better than just seeking a solution and getting nothing but that.

    The message basically means that you're trying to pass a value or object which is not of the correct type for the variable/function/field/etc. that you are trying to pass it to. In your case, if you knew that meaning it would point you to look at how you declared the variable, in which case you probably would have spotted your error right away. Just trying to save you some grief and time by this. HTH.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi Micron
    I do try to search and investigate the errors that I get.

    I have now resolved this error with the following Code

    It might not be the best but it works.

    Code is:-
    Code:
    Private Sub cmdEMail_Click()
    
    
    10        On Error GoTo cmdEMail_Click_Error
          Dim db As DAO.Database
          Dim rs As DAO.Recordset
    
    
          Dim strSQL As String
          Dim OutApp As Object
          Dim OutMail As Object
          Dim emailTo As String
          Dim emailSubject As String
          Dim emailBody As String
    
    
    20        Set db = CurrentDb
    30        Set rs = db.OpenRecordset("Select Customer, EMail From qry_JobQuoteReminders")
    40        Do Until rs.EOF
    
    
    50            emailTo = rs.Fields("Customer").Value & " <" & rs.Fields("Email").Value & ">"
    60            emailSubject = "Quote"
    70            emailBody = "Please note that your Quote has not yet been confirmed."
    
    
    
    
    80    Set OutApp = CreateObject("Outlook.Application")
    90    Set OutMail = OutApp.CreateItem(0)
    
    
    100   On Error Resume Next
    
    
    110       Set OutMail = OutApp.CreateItem(olMailItem)
    120       OutMail.To = emailTo
    130       OutMail.Subject = emailSubject
    140       OutMail.Body = emailBody
    150       OutMail.Display
    
    
    160       rs.MoveNext
    170       Loop
    
    
    180       rs.Close
    190       Set rs = Nothing
    200       Set db = Nothing
    
    
    210       Set OutMail = Nothing
    220       Set OutApp = Nothing
              
    230       On Error GoTo 0
    240       Exit Sub
    
    
    cmdEMail_Click_Error:
    
    
    250       MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdEMail_Click, line " & Erl & "."
    
    
    End Sub
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I do try to search and investigate the errors that I get.
    Well that's a good thing. Then for this one, I guess that either you have never understood the documentation about the error, or did and forgot, or were just having a senior moment. I have those often. Today I was trying to help out with something and couldn't see why the syntax was wrong (using a sql statement for a recordset). Struggled for about 5 minutes with and without brackets, even tried a string variable and no luck. I looked it up and still couldn't see the issue. Then it hit me - requires an equals sign, dummy! I just wasn't seeing what I was reading.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi Micron
    Yes I have many of those sessions.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    Well for a start, there is no need to create An outlook app object for as many emails as you going to send?
    You should create the app object ONCE outside the loop, not each time inside the loop. If you do leave it inside the loop, you should set it to nothing inside the loop as well?

    You only set it to nothing once, outside the loop, so must have multiple outlook sessions hanging around, if more than one record in recordset?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Yes, app object should be set once outside the loop. Code in post 1 shows this.

    The mail object can be set within the loop if you want to open and display multiple email items.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-06-2021, 06:25 AM
  2. Replies: 13
    Last Post: 05-31-2019, 10:48 PM
  3. Replies: 3
    Last Post: 01-23-2014, 07:49 AM
  4. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums