|
-
Oct 28th, 2009, 02:14 AM
#1
Thread Starter
PowerPoster
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.
-
Oct 28th, 2009, 02:21 AM
#2
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....!!!
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 28th, 2009, 02:58 AM
#3
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 4th, 2009, 11:20 AM
#4
Thread Starter
PowerPoster
Re: import csv ind create new table
 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
-
Nov 4th, 2009, 02:52 PM
#5
New Member
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|