Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2018, 09:30 PM
macropod's Avatar
macropod macropod is offline MailMerge from txt file - failing when the file path contains a reserved SQL word Windows 7 64bit MailMerge from txt file - failing when the file path contains a reserved SQL word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Why not simply have the mailmerge main document connect directly to the database and apply whatever filtering you require within the mailmerge main document itself?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 10-21-2018, 04:26 PM
travb81 travb81 is offline MailMerge from txt file - failing when the file path contains a reserved SQL word Windows 10 MailMerge from txt file - failing when the file path contains a reserved SQL word Office 2016
Novice
MailMerge from txt file - failing when the file path contains a reserved SQL word
 
Join Date: Aug 2017
Posts: 11
travb81 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Why not simply have the mailmerge main document connect directly to the database and apply whatever filtering you require within the mailmerge main document itself?
Hi Paul,

I did try this initially. The issue I ran into, was the sql statement was very long and complex. Using the OpenDataSource function, the SQLStatement and SQLStatement1 parameters seemed to not be large enough for this query.

Working with Access regularly, it was easy to establish a connection and recordset, and throw the data I need into a file. It doesn't change very often, so this disconnected data works very well.
Reply With Quote
  #3  
Old 10-21-2018, 07:40 PM
macropod's Avatar
macropod macropod is offline MailMerge from txt file - failing when the file path contains a reserved SQL word Windows 7 64bit MailMerge from txt file - failing when the file path contains a reserved SQL word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,369
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by travb81 View Post
The issue I ran into, was the sql statement was very long and complex. Using the OpenDataSource function, the SQLStatement and SQLStatement1 parameters seemed to not be large enough for this query.
SQLStatement is suitable for query strings up to 255 characters. Where the query string is longer than 255 characters, you'd use SQLStatement1 for the remainder; there is no specified character limit for SQLStatement1.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 10-26-2018, 03:31 AM
travb81 travb81 is offline MailMerge from txt file - failing when the file path contains a reserved SQL word Windows 10 MailMerge from txt file - failing when the file path contains a reserved SQL word Office 2016
Novice
MailMerge from txt file - failing when the file path contains a reserved SQL word
 
Join Date: Aug 2017
Posts: 11
travb81 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
SQLStatement is suitable for query strings up to 255 characters. Where the query string is longer than 255 characters, you'd use SQLStatement1 for the remainder; there is no specified character limit for SQLStatement1.
Hi Paul,
Are you sure SQLStatement1 accepts a longer string?

Code:
    
strSQL1 = Left(strSQL, 255)
strSQL2 = Right(strSQL, Len(strSQL) - 255)
My statement is 514 characters long, and the .OpenDataSource statement is throwing up runtime error 9105, 'string is longer than 255 characters'.
If I remove a few spaces or one of the WHERE criteria from the statement, it executes ok...

Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
MailMerge from txt file - failing when the file path contains a reserved SQL word Putting path and file name into all Word documents Kevin Beach Word 3 11-26-2016 06:14 PM
MailMerge from txt file - failing when the file path contains a reserved SQL word Determining file path for linked image in Word 2007 samhdc Word 7 01-26-2015 04:21 PM
MailMerge from txt file - failing when the file path contains a reserved SQL word Display Full File Path Name of Document in Title bar MS-Word 2010 Carlos06x Word 1 10-12-2011 10:39 AM
Programmatically get File Path for currently opened WORD document franferns Word 1 11-26-2009 12:36 PM
MailMerge from txt file - failing when the file path contains a reserved SQL word get file name without Path Ziggy1 Word VBA 1 09-29-2006 07:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft