Hi,
I already know how to import text file to datagrid,may i how to create the data report from the text file??
my text file content:
2310047019902,50,18/12/2013,08:24
2310057019909,80,18/12/2013,08:24
2310073019907,2000,18/12/2013,08:24
2310048019901,50000,18/12/2013,08:25
2310067019906,2,18/12/2013,08:25
my code:
Module
command button
your help is much appreciated
:confused::confused:
I already know how to import text file to datagrid,may i how to create the data report from the text file??
my text file content:
2310047019902,50,18/12/2013,08:24
2310057019909,80,18/12/2013,08:24
2310073019907,2000,18/12/2013,08:24
2310048019901,50000,18/12/2013,08:25
2310067019906,2,18/12/2013,08:25
my code:
Module
Code:
Option Explicit
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public Sub Connect()
Dim Path1 As String
Path1 = App.Path & "C:\aaa\test.txt"
cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\aaa\;Extended Properties=""text;HDR=No;FMT=Delimited"""
With rs
.ActiveConnection = cn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Source = "Select * From test.txt"
.Open
End With
End Sub
Public Sub RSCheck()
If rs.State = 1 Then rs.Close
End Sub
Code:
Private Sub Command1_Click()
Dim SQL As String
If rs Is Nothing Then
Set rs = New ADODB.Recordset
End If
RSCheck
SQL = "Select * From test.txt"
rs.Open SQL, cn, adOpenStatic, adLockReadOnly
Set DataReport1.DataSource = rs
DataReport1.Show
End Sub
Private Sub Form_Load()
Connect
If Not rs.BOF And Not rs.EOF Then
rs.Sort = "F1 ASC"
rs.Requery
Set DataGrid1.DataSource = rs
End If
End Sub
:confused::confused: