I'm getting the infamous Run Time Error '3021', and am having no luck resolving the issue. I have browsed countless forums and tried many different solutions, but none of them have worked for me.
This program is designed to send e-mails to appropriate people (determined by their field office location and "Mail Type"). It opens the recordset, loops through the records until it finds a person that matches BOTH criteria, sends the e-mail, and continues to loop through and sending messages to the appropriate people. The e-mails are sent through our smtp server to avoid the annoying Outlook security warnings.
The program cycles through the records as it should, but when it gets to the EOF, it throws the error. I have stepped through the code numerous times to try and understand what the heck is going on, but I'm only getting frustrated.
Code:
     With r
        If MailType <> "3" Then
            Do Until MailType = "3" And Location = "Lubbock"
            .MoveNext
            Loop
            If MailType = "3" And Location = "Lubbock" Then
                Do
                Call SendMail(r, d)
                .MoveNext
                Loop Until MailType <> "3" Or Location <> "Lubbock"
            End If
        ElseIf .EOF Then
            MsgBox "E-mails sent."
        End If
    End With
The error is thrown on the line "Loop Until MailType <> "3" Or..."
For each time it runs through the loop, I hold my mouse over the MailType and Location variables to check the values it is finding. When it gets to the EOF, the variables return no value (meaning it is as .EOF), but it still throws the error. It doesn't even make it to the ElseIf statement.
The code runs PERFECTLY on my local hard drive, but when I try to run the code from the db that is saved on the server, the error is thrown. The code is identical, and the database is set up exactly the same. It is a mystery to me why it doesn't work on the server, but will on my PC.
It may be that I have not set up my loops correctly, but I'm not sure. Any help/advice y'all can give me will be much appreciated.
Thanks in advance.