Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Hello,
I created an Access 2000 database that opens up Word 2000 documents for merging. Within the Word 2000 document version is the following code. It pulls records from the Access database based upon the record creation date and a "typist" field. It works like a charm in 2000, but when it runs from 2003 the message that no records were found displays. Please help! Thanks. Private Sub Document_Open() Dim CreationDate As Variant, Initials As Variant, ErrorNumber As Long Do CreationDate = InputBox("Please enter the letter creation date below:" & vbCrLf & _ vbCrLf & "Date Format: mm/dd/yy", "Und23 Letter - Input Required") If IsNull(CreationDate) Then Exit Sub Initials = InputBox("Please enter your initials below:", "Und23 Letter - Input Required") If IsNull(Initials) Then Exit Sub On Error Resume Next ActiveDocument.MailMerge.DataSource.QueryString = _ "SELECT * FROM [Und23] WHERE (([CreateDate] = #" & CreationDate & "#) AND ([Typist] = " & Chr(34) & Initials & Chr(34) & "))" With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = False With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=True End With ErrorNumber = Err.Number If ErrorNumber 0 Then If MsgBox("There were no records that matched your search criteria. Do you want to try again?", vbQuestion Or vbYesNo, "No records found") = vbNo Then ErrorNumber = 0 End If Else ThisDocument.Close SaveChanges:=wdDoNotSaveChanges End If On Error GoTo 0 Loop Until ErrorNumber = 0 End Sub |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I created an Access 2000 database that opens up Word 2000 documents for
merging. Within the Word 2000 document version is the following code. It pulls records from the Access database based upon the record creation date and a "typist" field. It works like a charm in 2000, but when it runs from 2003 the message that no records were found displays. Please help! Thanks. Could you comment out "On Error Resume Next", run your code, and tell us on which line it's failing? Please also quote the exact message. Or is the problem occurring before the code even executes? Based on experience, I'm guessing you're running into this issue: http://support.microsoft.com?kbid=825765 When this security mechanism is activated (no Registry key to turn it off), opening a main merge document via code automatically disconnects the data source. You need to reconnect the data source using the OpenDataSource method (or set the Registry key). Private Sub Document_Open() Dim CreationDate As Variant, Initials As Variant, ErrorNumber As Long Do CreationDate = InputBox("Please enter the letter creation date below:" & vbCrLf & _ vbCrLf & "Date Format: mm/dd/yy", "Und23 Letter - Input Required") If IsNull(CreationDate) Then Exit Sub Initials = InputBox("Please enter your initials below:", "Und23 Letter - Input Required") If IsNull(Initials) Then Exit Sub On Error Resume Next ActiveDocument.MailMerge.DataSource.QueryString = _ "SELECT * FROM [Und23] WHERE (([CreateDate] = #" & CreationDate & "#) AND ([Typist] = " & Chr(34) & Initials & Chr(34) & "))" With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = False With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=True End With ErrorNumber = Err.Number If ErrorNumber 0 Then If MsgBox("There were no records that matched your search criteria. Do you want to try again?", vbQuestion Or vbYesNo, "No records found") = vbNo Then ErrorNumber = 0 End If Else ThisDocument.Close SaveChanges:=wdDoNotSaveChanges End If On Error GoTo 0 Loop Until ErrorNumber = 0 End Sub Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]() Cindy M -WordMVP- wrote: I created an Access 2000 database that opens up Word 2000 documents for merging. Within the Word 2000 document version is the following code. It pulls records from the Access database based upon the record creation date and a "typist" field. It works like a charm in 2000, but when it runs from 2003 the message that no records were found displays. Please help! Thanks. Could you comment out "On Error Resume Next", run your code, and tell us on which line it's failing? Please also quote the exact message. Or is the problem occurring before the code even executes? Based on experience, I'm guessing you're running into this issue: http://support.microsoft.com?kbid=825765 When this security mechanism is activated (no Registry key to turn it off), opening a main merge document via code automatically disconnects the data source. You need to reconnect the data source using the OpenDataSource method (or set the Registry key). Private Sub Document_Open() Dim CreationDate As Variant, Initials As Variant, ErrorNumber As Long Do CreationDate = InputBox("Please enter the letter creation date below:" & vbCrLf & _ vbCrLf & "Date Format: mm/dd/yy", "Und23 Letter - Input Required") If IsNull(CreationDate) Then Exit Sub Initials = InputBox("Please enter your initials below:", "Und23 Letter - Input Required") If IsNull(Initials) Then Exit Sub On Error Resume Next ActiveDocument.MailMerge.DataSource.QueryString = _ "SELECT * FROM [Und23] WHERE (([CreateDate] = #" & CreationDate & "#) AND ([Typist] = " & Chr(34) & Initials & Chr(34) & "))" With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .MailAsAttachment = False .MailAddressFieldName = "" .MailSubject = "" .SuppressBlankLines = False With .DataSource .FirstRecord = wdDefaultFirstRecord .LastRecord = wdDefaultLastRecord End With .Execute Pause:=True End With ErrorNumber = Err.Number If ErrorNumber 0 Then If MsgBox("There were no records that matched your search criteria. Do you want to try again?", vbQuestion Or vbYesNo, "No records found") = vbNo Then ErrorNumber = 0 End If Else ThisDocument.Close SaveChanges:=wdDoNotSaveChanges End If On Error GoTo 0 Loop Until ErrorNumber = 0 End Sub Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) Cindy, The SQLSecurityCheck in regedit resolved my issue. Thank you! |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Word should catalog misspelled words to study. | Microsoft Word Help | |||
Word 97 in Windows XP to maintain formatting | Microsoft Word Help | |||
WP merge file to Word | Tables | |||
Word 2003 Mailmerge problem - works in Word 2000 | Mailmerge | |||
In Word, how can I see all files (*.*) in "save as"? | New Users |