View Single Post
 
Old 01-04-2016, 06:43 AM
jmo jmo is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Dec 2015
Posts: 7
jmo is on a distinguished road
Default Merge Object and not displaying Access Queries with VBA

I tried copying the sqlstatement provided by a manual mail-merge but it still will not look at the queries with the VBA code.

Macropod. I apologize. I'm very new to Office coding and so really all I'm wanting to do is part of the 'run the document' code I have is to have it automatically open up the mail-merge prompts including the connection type.

We have about 12 different queries (one for each program manager) that links to the same table. I wanted them to manually select their own query (or someone elses, if they're filling in) from a list of all the queries.

Really I just want when I have the code say 'run the mail merge' that all the boxes pop up as if I'd hit the button. If there's a specific SQLString that does that I'll give it a try the one I copied doesn't seem to do the DDE connection so the queries with VBA functions don't appear.

The code that will use what I'm trying to do is here:

Quote:
Private Sub RUN_Click()
Dim DBLoc As String
If FundSource.Value = "" Or FedFunds.Value = "" Or Match.Value = "" Or ServiceCharges.Value = "" Or Equipment.Value = "" Or DiscloseInfo.Value = "" Or FFATA.Value = "" Then
MsgBox ("ERROR: One or more option fields are blank. All fields must be set.")
Else
With ActiveDocument.CustomDocumentProperties
.Add Name:="FundSource", Type:=msoPropertyTypeString, Value:=FundSource.Value, LinkToContent:=False
.Add Name:="FedFunds", Type:=msoPropertyTypeString, Value:=FedFunds.Value, LinkToContent:=False
.Add Name:="Match", Type:=msoPropertyTypeString, Value:=Match.Value, LinkToContent:=False
.Add Name:="ServiceCharges", Type:=msoPropertyTypeString, Value:=ServiceCharges.Value, LinkToContent:=False
.Add Name:="Equipment", Type:=msoPropertyTypeString, Value:=Equipment.Value, LinkToContent:=False
.Add Name:="DiscloseInfo", Type:=msoPropertyTypeString, Value:=DiscloseInfo.Value, LinkToContent:=False
.Add Name:="FFATA", Type:=msoPropertyTypeString, Value:=FFATA.Value, LinkToContent:=False
.Add Name:="DBYear", Type:=msoPropertyTypeString, Value:=DBYear.Value, LinkToContent:=False
End With
ActiveDocument.Fields.Update
'MSGBOX will change text/move location/as more parts of the code work.
MsgBox ("Contract Created. Double Check Margins.")
‘MAIL MERGE CODE HERE
With Application.Dialogs(wdDialogFileSaveAs)
.Name = "h:\RDS\ASSESS\Program Files\#UNK AGENCY NAME Unsigned Contract.doc"
.Format = wdFormatDocument
.Show
End With
Unload Me
End If
End Sub
Reply With Quote