Access not responding after running VBA macro (1 Viewer)

jessss

Registered User.
Local time
Today, 12:46
Joined
Jan 17, 2010
Messages
29
Good Morning, i was wondering if someone could help me with an issue i am having with Access.

Currently i have a system which is a Access which is running two macros. the first one creates a new record in two different tables. The second exports a query, then opens a word mail merge document and loops through the records and prints each to PDF. Then it loops through the records in the query export and generates new emails and attached the PDF to them.

The problem is that the first macro runs perfectly and everything works. The second macro runs fine until it finishes, when it gets to "end sub" Access appears to crash and when you try to click anyway the access screen then goes white. To me looks like access is waiting for you to click a message box but i cannot see anything.

I have tried stepping through the macro and everything seems to be working it steps through everything and completes fine but access just seesm to not be working.

Does anyone have any ideas of what i can do to find out what is happening with access?

Thank you
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:46
Joined
Feb 19, 2013
Messages
16,555
going white can mean you are in an endless loop, but purely a guess. Have you checked whether a message box has opened behind another window?

Suggest provide the code.
 

jessss

Registered User.
Local time
Today, 12:46
Joined
Jan 17, 2010
Messages
29
Thank you for replying. i think i have fixed it. i had a go at running the macro in sections to find out when access starts to crash and i found out it was after it ran the code "Application.Echo False" which is in the section. i am unsure of why that line of code caused the issue but once i commented it out everything worked fine
Code:
Application.Echo False
strFilePath = "O:\CRM\MEB\MEB Letters\Member_Contract_Docs_Email.docx"
Set MainDoc = GetObject(strFilePath, "Word.Document")
MainDoc.Application.Visible = True
StrFolder = "O:\CRM\MEB\ContractDocs\Temp"
strName1 = "Member Contract Documents"
MainDoc.Application.Activate
    MainDoc.MailMerge.OpenDataSource _
    name:="O:\CRM\MEB\printing.xls", _
    LinkToSource:=True, _
    SQLStatement:="SELECT * FROM [qryContractBatch$]"
MainDoc.MailMerge.ViewMailMergeFieldCodes = wdToggle
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:46
Joined
Feb 28, 2001
Messages
27,001
Echo False means "shut up and don't tell me anything while running." Which means it did finish but you had told it to not tell you that.
If you ended the macro with Application.Echo True, it would also have fixed the problem, I think.
 

Users who are viewing this thread

Top Bottom