CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2099|Reply: 4

salammmm....

[Copy link]
erin_0502 This user has been deleted
Post time 20-8-2007 01:47 PM | Show all posts |Read mode
nak tanye camane nak transfer taex pada text file tapi xnak semua column.....nak pilih column yang penting je....
ni coding erin

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 i As Integer
    Dim strFilename As String
    Dim sExportLocation As String
    Dim Expression As String
    Dim returnValue() As String
  
    Set db = CurrentDb()
   
    sExportLocation = "N:\- Guest -\guestbcs\usrPrivate\irni\irni\access\"
    For Each td In db.TableDefs 'Tables
        If Left(td.Name, 4) <> "MSys" Then
            strFilename = sExportLocation & td.Name & ".txt"
            Debug.Print strFilename
            DoCmd.TransferText acExportDelim, , td.Name, strFilename, False
        End If
    Next td
     
    For i = 0 To db.QueryDefs.Count - 1
        Application.SaveAsText acQuery, db.QueryDefs(i).Name, sExportLocation & 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

tau x camane nak tambah....
Reply

Use magic Report


ADVERTISEMENT


Post time 22-8-2007 09:06 AM | Show all posts
ini vb ker??? aduh dah lama tinggal vb.... u pakai table jenis apa? msGrid ker? yang ada column2 kat interface u tuh..
Reply

Use magic Report

Post time 22-8-2007 10:32 AM | Show all posts

Reply #1 erin_0502's post

VBA for Microsoft Access nih.

Nape tak buat je query baru, select column yang dikehendaki, then expore query baru tu ke text file?
Reply

Use magic Report

Post time 22-8-2007 01:39 PM | Show all posts
not maksud aku.. table kat screen tuh.. mean msflexgrid ker.. cara mudah .. u design msflexgrid dulu, ambek kat component/control.. if u tau guna control2 tuh rasa takde masalah.. cara shahnaz tuh btul.. yg penting u tau how to retrieve data by data in column tuh dulu.. then baru u insert in text..
Reply

Use magic Report

Post time 22-8-2007 01:42 PM | Show all posts
i nk tunjuk coding pun takleh.. takde installer vb, malas nk dunload .. lagipun contoh2 project i guna vb pun ada kat kg.. aduh.. ruginya xdapat bkongsi.. takpe i try cari.. saba eks..


cam kes ini utk datagrid..

Private Sub DGrid DblClick()
    With DGrid
            yourVariable =
.Columns(0).Text. " , ".Columns((1).Text
     End With
Dim sFileText as String
Dim iFileNo as Integer
  iFileNo = FreeFile
      'open the file for writing
  Open "C:\Test.txt" For Output As #iFileNo
      'write some example text to the file
  Print #iFileNo,
yourVarible
  Close #iFileNo

End Sub


pastu your letak variable tuh..

camtuhla serba sedikit.. ko ubah la ikut kesesuaian

[ Last edited by  liverpoolfctv at 22-8-2007 02:00 PM ]
Reply

Use magic Report

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 03:35 AM GMT+8 , Processed in 0.041244 second(s), 16 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list