File Streaming (I/O)

tranchemontaigne

Registered User.
Local time
Today, 01:48
Joined
Aug 12, 2008
Messages
203
Recently I ran into a problem where I used the "Microsoft Scriptlet Library" to create external files and write content to them as part of an HL7 messaging integration. The problem with this approach is that the default encoding used when writing strings to these files was UTF-8 (a two bit character encoding scheme), when the consuming system required a single bit character encoding scheme such as Windows-1252 or ASCII.

I worked through the problem by using "Microsoft ActiveX Data Objects 2.8 Library" and the ADODB.Stream object to create files and write content to them because it accepts an encoding scheme parameter.

Fortunately, all my code used ADODB recordsets, so calling a previously referenced library for something else was trivial. Given the apparent preference for DAO among MS Access developers, I was curious to learn how a developer who prefers DAO would have solved this problem.
 
As a note: If you keep your Dim statements disambiguate, there is no conflict with having both ADO and DAO libraries referenced.
 
How would I dismabiguate? My code compiles just fine without a reference to the DAO 3.6 library, but adding a reference to that library alone generates a

Name conflicts with existing module, project, or object library

error. All of my recordset DIM statements look similar to this

Code:
Dim rst1 As ADODB.Recordset

My file I/O DIM looks like this

Code:
Dim BinaryStream
  Set BinaryStream = CreateObject("ADODB.Stream")


The only references in the database run as follows:
(1) Visual Basic for Applications
(2) Microsoft Access 14.0 Object Library
(3) OLE Automation
(4) Microsoft Office 14.0 Access database engine Object Library
(5) Microsoft ActiveX Data Objects 2.8 Library


(PS: I'm running Office 2010 Professional on Windows 7.
 
Last edited:
Your using Late Binding and that should work for DAO as well.
 
I do recall concurrently referencing ADO and DAO libraries and having no compiler or run-time errors in MS Access 2000.

(We just upgraded from MS Office 2000 to MS Office 2010 about a year ago - the same time we upgraded from Windows XP.)
 
If you use Late Binding "Dim Whatever As Object" you do not even have to have the reference. Later versions of MS Access are pickier. There are name conflicts between the ADODB and DAO libraries. I suspect, though it is just a guess, that the error is not critical and will allow you to use early binding with both libraries as long as you disambiguate.
 
The name conflict won't occur if ALL objects are DIM'd as disambiguated. It is only things that overloap between DAO and ADO that can have this problem, and the biggest - but certainly not the only - culprit is recordsets.
 

Users who are viewing this thread

Back
Top Bottom