You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description
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.
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
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
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
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
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
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
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.
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
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.I do try to search and investigate the errors that I get.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
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
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
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.