Share via

SQL command runs when opening Word document

Anonymous
2019-11-21T14:54:46+00:00

Hello,

I have been given a mail merge Word document that runs an SQL command on opening. I cannot figure out where to view the code to change it. I currently hit the NO button when asked if I want to run the query, as it points to a non-existent data source now.

Thanks!

Jim Calabrese

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Doug Robbins - MVP - Office Apps and Services 323K Reputation points MVP Volunteer Moderator
2019-11-22T04:48:44+00:00

It is normal for that message to appear when you open a mail merge main document that has\had a data source attached to it.  

If you click on No, the link to the data source will be broken and you can then use the Select Recipients facility to select the data source that you want to use with the mail merge main document.

It is not really feasible to modify the SQL code, far easier to attach\re-attach the data source.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2019-11-21T21:41:32+00:00

    Hi Jim,

    Thanks for posting the question on our forum.

    According to your description, you may meet the "Opening this will run the following SQL command" message when you open a Word mail merge main document that is linked to a data source.

    Here is an article is focus on the situation, you can refer to it:

    You receive the "Opening this will run the following SQL command" message when you open a Word mail merge main document that is linked to a data source

    Besides, you can refer to the following thread to check if it can help you:

    How do I change the SQL SELECT statement used to retrieve fields in a mail-merge?

    Although, the two articles are old, they may be helpful.

    IF this can’t help you, you are welcome to post back and provide the screenshot of error message and Office version. (Click File>select Account) I will keep working on this.

    Regards,

    Qing

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2019-11-22T13:59:11+00:00

    Thanks!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2019-11-22T13:55:24+00:00

    Ok, so i see that the "Select" code is actually selecting my new data source file. I think I'll just turn off the message prompt.

    Thanks for your help!

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2019-11-22T13:47:32+00:00

    I can do that just fine, but every time I open the document it tries to connect to the old data source. Is there a way to permanently replace the data source?

    Was this answer helpful?

    0 comments No comments