Solved

Data from Access to Text and Excell with only distributable references and Components

Posted on 1998-09-09
7
128 Views
Last Modified: 2010-08-05
I need to get data from an Access table into a text file inside Visual Basic 5.0 without using any references that cannot be freely shipped.  Record by Record.  I have tried many things.  but nothing I have found seems complete enough to work.
0
Comment
Question by:pennymurray
7 Comments
 

Expert Comment

by:firefox032697
ID: 1433932
What references do you believe can not be freely shipped?

The laws may be different in your country and am I am not a lawyer nor am I connected with the legal profession in anyway, so please do not interpret this as legal advice. But - as I read the licence agreement shipped with VB Enterprise you can redistribute the runtime libraries for DAO and RDO but there is a fairly convoluted constraint re MS-Office - other editions of VB may have other constraints. Again, I am not a lawyer so you should list the references and seek a solicitors opinion.

To look at it another way if you couldn't ship the run time libaries to access an MS-Access table, what use is VB for building a commercial application?

0
 

Author Comment

by:pennymurray
ID: 1433933
I tried to use the Microsoft Access 8.0 Object library but you cannot redistribute those libraries.  That is what I meant I think I know what track I need to be on but I cannot find an example.  I believe I have to use the Open and Write or Put statements but I am not sure of the most efficient way to code those as I have never used them before and one of my tables has 110 fields and I hate to have to append those fields even in code.  so if Someone has some suggestion or an example I would love them forever ha ha.
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1433934
Penny, don't use the Access 8.0 library, but use DAO in VB to read your table and get it into a text file.  This is freely distributable with your vb application and will be included in your install by the setup wizard.  For something as trivial as what you want to do, using the Access Object library is like using a sledgehammer to drive tacks!  Pick up and modify one of the many examples in vb help (Opendatabase, etc) and it will get you on your way.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:pennymurray
ID: 1433935
I know more than that.  I need to use the Open, put and Get statements.  I already have an answer and I will post the code tomorrow.
0
 

Author Comment

by:pennymurray
ID: 1433936
Private Type ClaimRecord 'Define user-defined Type
        ReportingPolicy As String * 2
        ClaimNo As String * 4
        ClaimGroupNo As String * 3
        ClaimGroupSequence As String * 2



End Type


lnRecord = 1
        lsSQL = "Select * from ClaimTable"
        Set lrsExport = gdbReportData.OpenRecordSet(lsSQL, dbOpenDynaset)
        lrsExport.MoveFirst
        Open "d:\reporting system\TestClaim.txt" For Random Access Read Write As #1 Len = 1125
        lrecRecord.ReportingPolicy = lrsExport.Fields(0).Name  ' trying to get headers somehow
       
        lrecRecord.ClaimNo = lrsExport.Fields(1).Name
        lrecRecord.ClaimGroupNo = lrsExport.Fields(2).Name
        lrecRecord.ClaimGroupSequence = lrsExport.Fields(3).Name

        Put #1, lnRecord, lrecRecord
       
        Do While Not lrsExport.EOF
            lnRecord = lnRecord + 1
            If IsNull(lrsExport.Fields(0)) Then
                lrecRecord.ReportingPolicy = ""
            Else
                lrecRecord.ReportingPolicy = lrsExport.Fields(0)
            End If
            If IsNull(lrsExport.Fields(1)) Then
                lrecRecord.ClaimNo = ""
            Else
                lrecRecord.ClaimNo = lrsExport.Fields(1)
            End If
            If IsNull(lrsExport.Fields(2)) Then
                lrecRecord.ClaimGroupNo = ""
            Else
                lrecRecord.ClaimGroupNo = lrsExport.Fields(2)
            End If
            If IsNull(lrsExport.Fields(3)) Then
                lrecRecord.ClaimGroupSequence = ""
            Else
                lrecRecord.ClaimGroupSequence = lrsExport.Fields(3)
            End If
            Put #1, , Chr(13) & Chr(10)
            Put #1, lnRecord, lrecRecord
            lrsExport.MoveNext
        Loop
        Close #1

This puts 1 line into a text file and appends each record to the end of that line This question is still worth full points if you can help me to get headers and and records on separate lines.

Thanks,
Penny
0
 

Author Comment

by:pennymurray
ID: 1433937
added a field to the Type called EndOfRecord and set it equal to VBKeyReturn.  I solved it myself so I will not give points to anyone else.  Thanks,Penny
0
 
LVL 7

Accepted Solution

by:
linda101698 earned 100 total points
ID: 1433938
I am posting the solution found by pennymurray so it can be saved in the previously asked questions. Penny, please see your customer service question for an explanation.

Linda Gardner
Customer Service @ Experts Exchange

Comment
     From: pennymurray
                                   Date: Friday, September 11 1998 - 08:23AM PDT

     Private Type ClaimRecord 'Define user-defined Type
             ReportingPolicy As String * 2
             ClaimNo As String * 4
             ClaimGroupNo As String * 3
             ClaimGroupSequence As String * 2



     End Type


     lnRecord = 1
             lsSQL = "Select * from ClaimTable"
             Set lrsExport = gdbReportData.OpenRecordSet(lsSQL,
     dbOpenDynaset)
             lrsExport.MoveFirst
             Open "d:\reporting system\TestClaim.txt" For Random Access Read
     Write As #1 Len = 1125
             lrecRecord.ReportingPolicy = lrsExport.Fields(0).Name  ' trying to get
     headers somehow
             
             lrecRecord.ClaimNo = lrsExport.Fields(1).Name
             lrecRecord.ClaimGroupNo = lrsExport.Fields(2).Name
             lrecRecord.ClaimGroupSequence = lrsExport.Fields(3).Name

             Put #1, lnRecord, lrecRecord
             
             Do While Not lrsExport.EOF
                 lnRecord = lnRecord + 1
                 If IsNull(lrsExport.Fields(0)) Then
                     lrecRecord.ReportingPolicy = ""
                 Else
                     lrecRecord.ReportingPolicy = lrsExport.Fields(0)
                 End If
                 If IsNull(lrsExport.Fields(1)) Then
                     lrecRecord.ClaimNo = ""
                 Else
                     lrecRecord.ClaimNo = lrsExport.Fields(1)
                 End If
                 If IsNull(lrsExport.Fields(2)) Then
                     lrecRecord.ClaimGroupNo = ""
                 Else
                     lrecRecord.ClaimGroupNo = lrsExport.Fields(2)
                 End If
                 If IsNull(lrsExport.Fields(3)) Then
                     lrecRecord.ClaimGroupSequence = ""
                 Else
                     lrecRecord.ClaimGroupSequence = lrsExport.Fields(3)
                 End If
                 Put #1, , Chr(13) & Chr(10)
                 Put #1, lnRecord, lrecRecord
                 lrsExport.MoveNext
             Loop
             Close #1

     This puts 1 line into a text file and appends each record to the end of that line
     This question is still worth full points if you can help me to get headers and
     and records on separate lines.

added a field to the Type called EndOfRecord and set it equal to
     VBKeyReturn.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now