Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ms access - get external data 1

Status
Not open for further replies.

piti

Technical User
Apr 12, 2001
627
SK
hi there
anybody here who knows how to start and control the import text wizzard in ms access2000?
or any other way how to import data from a text file into a table
thanx
 
Do you want to start it from within VB? If not open ACCESS, go to the File menu, > Get External Data > Import. If you want to open the file from within vb then access the table,this should get you started:

Dim cnConn as adodb.connection
dim sLine as String
Dim iFileNum as integer
Dim sSQL as string
dim vOne,vTwo,vThree as string

set cnConn = createobject("ADOdb.connection")
iFileNum = Freefile
Open "C:\yourfilepath" For Input As #iFileNum

cnConn.connectionstring = "Driver={Microsoft Access Driver (*.mdb)};Dbq="C:\YourPath";Uid=Admin;Pwd=;"
cnconn.open

Do Until EOF(iFileHeader)
Line Input #iFilenum, sLine
'set the variables to your file structure
vOne = Mid$(slIne,2,4)
'vtwo = something
'vthree = something


ssQL = "INSERT INTO TABLE(F1,F2F3,)VALUES('" & vOne & "' & "," & '" & vTwo & "' & "," & '" vThree & "' & ")"

cnConn.execute ssql
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top