[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Simple  VBA write text file

Asked by avgplusguy in Access Coding/Macros, VB Controls

Tags: vba, write, file, text

MS Access 2003 writing MS Access 2000 database.
I just started trying to write VBA and put two previous code pieces together and of course it does not work. I want to pass a three letter code that will be used to open a table where the entity = abbreviation.
I want to write out a text file that is named that abbreviation.   Table APR_DRG,

Here is code that needs some help

Sub ExportTstar()
    Dim cnn As New DAO.Connection
    Dim db As DAO.Database
    Dim rs As New DAO.Recordset
    Dim fso As Object
    Dim ts As Object
    Dim Abbrev As String
       
        Abbrev = InputBox("Please enter Enity")
    If Abbrev = "" Then
        MsgBox "Abort", vbCritical
        Exit Sub
    End If

' DoCmd.OpenQuery "qBAS", acNormal, acEdit

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.CreateTextFile("c:\" & Abbrev & ".ctf", True)
    Set rs = db.OpenRecordset("APR_DRG")
    Set cnn = CurrentProject.Connection
    With rs
        Set .ActiveConnection = cnn
    '    .Open "SELECT * FROM [APR_DRG] WHERE [Entity]= Abbrev "
     
        .MoveFirst
        Do While Not .EOF
            ts.WriteLine "CHA," & ![ACCOUNT_NO] & ", " & ![Discharge_Date]
            ts.WriteLine ".APRDRG :" & ![APR20_DRG]
            ts.WriteLine ".APR_MDC" & ![APR_MDC]
            ts.WriteLine ".APRSUB :" & ![APR20_SOI]
            ts.WriteLine ".APRRMOR :" & ![APR20_ROM]
            ts.WriteLine "APR_CMI :" & ![APR20_CMI]
            ts.WriteLine "3MDRG_V24 :" & ![CMS24_DRG]
            ts.WriteLine "3MDRG_V25 :" & ![CMS25_DRG]
                       
        .MoveNext
        Loop
    End With
   
    Set rs = Nothing
    Set cnn = Nothing
        ts.Close
    Set ts = Nothing
    Set fso = Nothing
    MsgBox "Done"

End Sub


 
[+][-]11/12/07 09:12 PM, ID: 20269609Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Access Coding/Macros, VB Controls
Tags: vba, write, file, text
Sign Up Now!
Solution Provided By: frankytee
Participating Experts: 1
Solution Grade: A
 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_2_20070628