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:
  1. Sub Marco1()
  2. '
  3. ' Macro1 Macro
  4. ' Macro recorded 6/27/2005 by Sarah Ransome
  5. '
  6.     Set wdApp = CreateObject("Word.Application")
  7.     With wdApp
  8.         .Visible = False
  9.         Documents.Open FileName:="C:\Documents and Settings\sransome\My Documents\permitAtt.doc", ConfirmConversions:=True, _
  10.         ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
  11.         PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
  12.         WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
  13.     ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
  14.    
  15.    
  16.  
  17.     ActiveDocument.MailMerge.OpenDataSource Name:= _
  18.     "C:\Inetpub\wwwroot\campbookings1\fpdb\indexJune26.mdb", _
  19.         LinkToSource:=True, AddToRecentFiles:=False, _
  20.         Format:=wdOpenFormatAuto, Connection:= _
  21. "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\campbookings1\fpdb\indexJune26.mdb;", _
  22. SQLStatement:="SELECT * FROM ATTAWANDARON3 WHERE BOOKINGNUMBER=0"
  23.  
  24. [COLOR=Red]
  25. If RecordFound <> 0 Then
  26. Response.Write ("")
  27. Else
  28. Response.Write ("SQLStatement")
  29. End If[/COLOR]
  30. End With
  31.  
  32.  
  33.  
  34.     With ActiveDocument.MailMerge
  35.         .Destination = wdSendToEmail
  36.         .SuppressBlankLines = True
  37.         With .DataSource
  38.             .FirstRecord = wdDefaultFirstRecord
  39.             .LastRecord = wdDefaultLastRecord
  40.         End With
  41.         .Execute Pause:=False
  42.     End With
  43.     ActiveDocument.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. End Sub