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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question: Need path and filename for file import??

Status
Not open for further replies.

KellyStee

Technical User
Jul 30, 2001
106
US
Hi! I'm trying to import a text file using a schema.ini file. I want the user to be able to browse for the file and select the file and import it. I've seen the code to browse for the directory and I've seen the code to choose a file and they seem to be very two large and different pieces of code (I've found the code here: and here: I think I need the two separate pieces of information because of my code below. Is there a way to get the path from code for File Open/Save Dialog box or a way to edit my code below to just have the full path and filename all returned at one time?

Set tbl = Db.CreateTableDef("Imported Data")
tbl.Connect = "Text;DATABASE=" & szPath & ";TABLE=Extract.txt"
tbl.SourceTableName = "Extract.txt"
Db.TableDefs.Append tbl
Db.TableDefs.Refresh

I'm a newbie here, so sorry if my questions don't make a lot of sense!!!

Kelly
 
Give this a try... Make sure that you have the Microsoft Common Dialog control loaded (Click More Controls... from the toolbox). Hope I understood what you were looking for. Good luck!

-Jeff

Private Sub cmd1_Click()
Dim CD As New MSComDlg.CommonDialog
CD.Filter = "All Files (*.*)|*.*"
CD.Flags = cdlOFNAllowMultiselect Or cdlOFNHideReadOnly Or cdlOFNFileMustExist
CD.ShowOpen

MsgBox CD.FileName
 
Sorry, but I guess I should have said...
'code...
CD.Flags = cdlOFNLongNames
'code...

That's probably what you are looking for.

-Jeff
 
Hi Kelly, I've posted a tip on how to retrieve the Folder and File Name: thread705-457897

To use it for your question, if you've got the Microsoft Common Dialog Control:

On Error GoTo ErrCommonDialog2
gInitDir = "C:"
Set gCommonDialog = Me!CommonDialog1
OpenCommonDialog
GetFileInfo (gFileName)
Set tbl = Db.CreateTableDef("Imported Data")
tbl.Connect = "Text;DATABASE=" & glPath & ";TABLE=" & glFileName
tbl.SourceTableName = glFileName
Db.TableDefs.Append tbl
Db.TableDefs.Refresh
ErrCommonDialog2:


If you haven't:

On Error GoTo ErrCommonDialog1
GetFileInformation (Find_File(glInitDir))
Set tbl = Db.CreateTableDef("Imported Data")
tbl.Connect = "Text;DATABASE=" & glPath & ";TABLE=" & glFileName
tbl.SourceTableName = glFileName
Db.TableDefs.Append tbl
Db.TableDefs.Refresh
ErrCommonDialog1:


 
billpower,
Just wanted to let you know that I read your thread and it worked!! Perfectly!! It was well-explained and was EXACTLY what I needed! Thanks so much!

Kelly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top