import csv ind create new table
with ado please...
I use the tipical ado conn.(the access database source is in c:\my_dir1 and is named test1.mdb)
In c:\my_dir\ have a file named test.csv (comma delimited).
The csv file contain the header name of column.
The column DATE contain a dates in usa format (mm/dd/yyyy).
The column AGENCY contain a values with 3 or 4 characters.
Now, via ADO or with other..., i need to create with the csv file a new table in the mdb test1.mdb named MYTABLE_&DATA (DATA is a datae variable)
but during the import of csv in table change the format of column DATE in dd/mm/yyyy and change the format of column AGENCY in #0000
tKS. i hope understand me.
Re: import csv ind create new table
Code:
me.caption=format(Date,"dd/mm/yyyy")
Some thing like this...???
Give us a detailed view of your problem....!!!
Re: import csv ind create new table
If you want to use the Access Object Model...
Code:
Option Explicit
'Add a reference to Microsoft Access xx.0 Object Library
Private moApp As Access.Application
Private Sub Command1_Click()
On Error GoTo My_Error
Set moApp = CreateObject("Access.Application")
moApp.DoCmd.SetWarnings False
moApp.OpenCurrentDatabase "C:\RobDog888.mdb"
moApp.DoCmd.TransferText acImportDelim, , "Table1", "C:\Test.csv", True
'Optionally show the table if you want confirmation it imported
'moApp.Visible = True
'moApp.DoCmd.OpenTable "Table1", acViewNormal, acEdit
moApp.DoCmd.SetWarnings True
Exit Sub
My_Error:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error GoTo My_Error
moApp.CurrentDb.Close
moApp.Quit acQuitPrompt
MyError:
Set moApp = Nothing
End Sub
Re: import csv ind create new table
Quote:
Originally Posted by
RobDog888
If you want to use the Access Object Model...
Code:
Option Explicit
'Add a reference to Microsoft Access xx.0 Object Library
Private moApp As Access.Application
Private Sub Command1_Click()
On Error GoTo My_Error
Set moApp = CreateObject("Access.Application")
moApp.DoCmd.SetWarnings False
moApp.OpenCurrentDatabase "C:\RobDog888.mdb"
moApp.DoCmd.TransferText acImportDelim, , "Table1", "C:\Test.csv", True
'Optionally show the table if you want confirmation it imported
'moApp.Visible = True
'moApp.DoCmd.OpenTable "Table1", acViewNormal, acEdit
moApp.DoCmd.SetWarnings True
Exit Sub
My_Error:
MsgBox Err.Number & " - " & Err.Description, vbOKOnly + vbExclamation
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error GoTo My_Error
moApp.CurrentDb.Close
moApp.Quit acQuitPrompt
MyError:
Set moApp = Nothing
End Sub
Hi friend.. and sorry for delay.
No. i want to use vb6 or vba for excel
Re: import csv ind create new table
Hello
to create the table Tbl_MYTABLE with VB6 you can use the following code:
Code:
'Crea la Tabella:
Private Sub Command1_Click()
Dim Conn As New ADODB.Connection
Dim OggTbl As New ADODB.Command
'Esegue la connessione con il DataBase:
Conn.ConnectionString = DBCon
Conn.CommandTimeout = 15
Conn.Open
'Crea la tabella Tbl_MYTABLE:
OggTbl.ActiveConnection = Conn
OggTbl.CommandType = adCmdText
OggTbl.CommandText = "create table Tbl_MYTABLE(IDCliente autoincrement primary Key, Nome Text(50) Not Null, Cognome Text(50) Not Null, Indirizzo Text(100))"
OggTbl.Execute
'Chiude e cancella la connessione:
Conn.Close
Set Conn = Nothing
End Sub
For the rest I did not quite understand... :)