Help... I'm in over my head
With much effort I got the following working... As long as I don't try to fancy it up...
The code in red is where it hangs up... All I want is that if there are no records equal to the sql... a message that says "No bookings".
Any help or suggestions?
VB Code:
Sub Marco1()
'
' Macro1 Macro
' Macro recorded 6/27/2005 by Sarah Ransome
'
Set wdApp = CreateObject("Word.Application")
With wdApp
.Visible = False
Documents.Open FileName:="C:\Documents and Settings\sransome\My Documents\permitAtt.doc", ConfirmConversions:=True, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Inetpub\wwwroot\campbookings1\fpdb\indexJune26.mdb", _
LinkToSource:=True, AddToRecentFiles:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\campbookings1\fpdb\indexJune26.mdb;", _
SQLStatement:="SELECT * FROM ATTAWANDARON3 WHERE BOOKINGNUMBER=0"
[COLOR=Red]
If RecordFound <> 0 Then
Response.Write ("")
Else
Response.Write ("SQLStatement")
End If[/COLOR]
End With
With ActiveDocument.MailMerge
.Destination = wdSendToEmail
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ActiveDocument.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
End Sub