CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2772|Reply: 7

salam.....nak tanyer sape yg pandai guna VB an MA Access ye...

[Copy link]
erin_0502 This user has been deleted
Post time 18-7-2007 12:32 PM | Show all posts |Read mode
saya kene tkr coding ni

Option Compare Database
Option Explicit

'Public Sub Main()
'ExportDatabaseObjects()
'End Sub

'Public Sub ExportDatabaseObjects()
Public Sub Main()
On Error GoTo Err_ExportDatabaseObjects
   
    Dim db As Database
    'Dim db As DAO.Database
    Dim td As TableDef
   'Dim d As Document
   'Dim c As Container
    Dim i As Integer
    Dim sExportLocation As String
   
    Set db = CurrentDb()
   
    sExportLocation = "N:\- Guest -\guestbcs\usrPrivate\irni\text file\.txt"
    For Each td In db.TableDefs 'Tables
        If Left(td.Name, 4) <> "MSys" Then
            DoCmd.TransferText acExportDelim, , td.Name, sExportLocation & "Table_" & td.Name & ".txt", True
            DoCmd.RunMacro "table_name"
        End If
    Next td
   
    For i = 0 To db.QueryDefs.Count - 1
        Application.SaveAsText acQuery, db.QueryDefs(i).Name, sExportLocation & "Query_" & db.QueryDefs(i).Name & ".txt"
    Next i
   
    Set db = Nothing

   
    MsgBox "All table been exported as a text file to " & sExportLocation, vbInformation
   
Exit_ExportDatabaseObjects:
    Exit Sub
   
Err_ExportDatabaseObjects:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_ExportDatabaseObjects
    End Sub

supaya output dia kuar camni lps export @ run :

745395|745393|86961||||0.07|3.14||311||||||ST|||m2|||
746427|746425|86961||||0.07|0.06||311||||||ST|||m|||
749978|749976|86961||||0.04|0.04||311||||||ST|||m|||
751819|751817|86961||||0.07|0.07||311||||||ST|||m|||
757316|757337|86961||||0.05|2.56||311|0|6.43|0.01|3||ST|||m2|||
757372|757337|86961||||0.05|2.79||694|0|6.50|-1.52|3||ST|||m2|||
757626|757624|86961||||0.03|2.75||311||||||ST|||m2|||
759779|759777|86961||||0.07|0.07||311||||||ST|||m|||
760870|760868|86961||||0.03|1.39||311||||||ST|||m2|||
760992|760990|86961||||0.03|2.75||311||||||ST|||m2|||
761161|761159|86961||||0.03|1.39||311||||||ST|||m2|||

kalau skang output die kuar camni:

745395,745393,86961,,,,0.07,3.14,,311,,,,,,"ST",,,"m2",,,
746427,746425,86961,,,,0.07,0.06,,311,,,,,,"ST",,,"m",,,
749978,749976,86961,,,,0.04,0.04,,311,,,,,,"ST",,,"m",,,
751819,751817,86961,,,,0.07,0.07,,311,,,,,,"ST",,,"m",,,
757316,757337,86961,,,,0.05,2.56,,311,0,6.43,0.01,3,,"ST",,,"m2",,,
757372,757337,86961,,,,0.05,2.79,,694,0,6.50,-1.52,3,,"ST",,,"m2",,,
757626,757624,86961,,,,0.03,2.75,,311,,,,,,"ST",,,"m2",,,
759779,759777,86961,,,,0.07,0.07,,311,,,,,,"ST",,,"m",,,
760870,760868,86961,,,,0.03,1.39,,311,,,,,,"ST",,,"m2",,,
760992,760990,86961,,,,0.03,2.75,,311,,,,,,"ST",,,"m2",,,

Bos kt sn xnak tnde comma banyak2, pls help me...
MEKASIH....................
Reply

Use magic Report


ADVERTISEMENT


Post time 19-7-2007 03:00 PM | Show all posts
google: acExportDelim pipe

ada few links yang akan pergi ke forums and discussions on how to change the delimiter to pipe (|) instead of comma (,) as well as to remove quotes ( " ). it involves creating / setup a specification file or a schema.ini file
Reply

Use magic Report

erin_0502 This user has been deleted
 Author| Post time 23-7-2007 02:07 PM | Show all posts

Reply #2 shahnazz's post

tp in this program xde pun tmpt yg letak comma...
u no with part?
Reply

Use magic Report

Post time 26-7-2007 04:04 PM | Show all posts
Bukankah Access VBA boleh diguna untuk buka text file ? Cuba buka Text file tu guna Access VBA kemudian guna Replace function untuk gantikan koma dengan pipe..... cua la, aku nak tau jugak ... aku ni berteori je.
Reply

Use magic Report

erin_0502 This user has been deleted
 Author| Post time 26-7-2007 04:32 PM | Show all posts

Reply #4 Oreng's post

macam mane tu....sry sbb erin xbiase dgn ms access @ vba ni...

bley gtau skt x camane nak buat...
Reply

Use magic Report

nice2000 This user has been deleted
Post time 26-7-2007 06:00 PM | Show all posts

Reply #3 erin_0502's post

rasa kamu ada letak koma kot dalam program tu.....
Reply

Use magic Report

Follow Us
Post time 26-7-2007 10:53 PM | Show all posts

Reply #3 erin_0502's post

refer balik aper yg shahnaz suruh google tue...

command DoCmd.TransferText

kan ader masukkan acExportDelim

yg inilah yg menyebabkan file tue jadi comma bila tranfer
Reply

Use magic Report

erin_0502 This user has been deleted
 Author| Post time 27-7-2007 08:58 AM | Show all posts

Reply #2 shahnazz's post

shahnaz ade contoh x...
erin dah cube search yg shahnaz ckp tu tp xdpt la.......
sry...
Reply

Use magic Report


ADVERTISEMENT


You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

3-1-2025 01:12 AM GMT+8 , Processed in 0.043894 second(s), 22 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list