Hi,
I have a button on a form which starts a macro, which does the following.
Setwarnings off
OpenQuery "QueryMergeData"
RunApp "C:\Program Files\Microsoft Office\Office\WINWORD.EXE" & "J:\Reports\BC\Admin\Merge.doc"
Setwarnings on
The Word Document uses data from a table that query has just created as it's datasource. I would like to convert this sequence into code, but before running the mail merge check that there is actually data in the table! If there is no data, then I want Access to inform the user with a message box and stop the mail merge from running.
Would something like this do the trick? Any suggestions would be welcome.
Private Sub Command132_Click()
DoCmd.RunQuery "QueryMergeData", acViewNormal (Do I need to have to specify an acView parameter?)
If DCount("*", "[TableMergeData]") > 0 Then
DoCmd.RunMacro ("MacroMailMerge") I don't know how to start Word and open the mail merge template using code!
Else
msgbox "No data to report, closing"
End If
End Sub
I'm assuming I can perform a DCount on a table, is this correct?
Thanks for any help,
FrankyG
I have a button on a form which starts a macro, which does the following.
Setwarnings off
OpenQuery "QueryMergeData"
RunApp "C:\Program Files\Microsoft Office\Office\WINWORD.EXE" & "J:\Reports\BC\Admin\Merge.doc"
Setwarnings on
The Word Document uses data from a table that query has just created as it's datasource. I would like to convert this sequence into code, but before running the mail merge check that there is actually data in the table! If there is no data, then I want Access to inform the user with a message box and stop the mail merge from running.
Would something like this do the trick? Any suggestions would be welcome.
Private Sub Command132_Click()
DoCmd.RunQuery "QueryMergeData", acViewNormal (Do I need to have to specify an acView parameter?)
If DCount("*", "[TableMergeData]") > 0 Then
DoCmd.RunMacro ("MacroMailMerge") I don't know how to start Word and open the mail merge template using code!
Else
msgbox "No data to report, closing"
End If
End Sub
I'm assuming I can perform a DCount on a table, is this correct?
Thanks for any help,
FrankyG