Word Merge SQL syntax

L

Lungta

I'm using Albert Kallal's Word Merge sample and managed to change the
recordsource to a query instead of picking up the controls from the open form.

The merge will be run from a cmd button on the case form (frmCase1) and I
need to specify a WHERE statement so it prints only the records associated
with the current CaseID. The textbox to be referenced is txtCaseID, field is
CaseID. How would I add the "where CaseID=frmCase1!CaseID"? I keep getting
error msg no matter which combination of quotes, etc. I use - either argument
not optional or no created, make sure the sql is correct. Would somebody be
able to point me in the right direction?

Option Compare Database
Option Explicit
Dim strSQL As String
Dim qryNotifLettersxl As String


Private Sub cmdMergeAll_Click()
strSQL = "Select * from qryNotifLettersxl"

Me.Refresh
' MergeAllWord ("select * from " & Me.RecordSource)
MergeAllWord ("select * from qryNotifLettersxl")

'Note that you could use a condtion in the above sql
End Sub

Thanks!
 
L

Lungta

Found it using the standalone db:
MergeAllWord ("select * from qryNotifLettersxl WHERE CaseID =" & [ContactID])

was trying to use the Single button and it won't take this sql

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top