Importing files from code

  • Thread starter Thread starter Justin Busch
  • Start date Start date
J

Justin Busch

I am currently working on a simple stepping stone to store student records.
What I would like to do is setup a form that when a Command Button is
pressed, an Open File Dialog box is created. The user can then select the
appropriate file and that filename and path is set to a string variable such
that I can use the doCmd.TransferText( acImportDelim, .....)

Is this possible and if so what is the best method of doing so?

Thank you
 
What I would like to do is setup a
form that when a Command Button is
pressed, an Open File Dialog box is
created. The user can then select the
appropriate file and that filename and
path is set to a string variable

http://www.mvps.org/access/api/api0001.htm describes how to directly use the
Windows Common Dialog via its API, and does exactly what you describe. It
even has sample code for how to use it.

Larry Linson
Microsoft Access MVP
 
Larry Linson said:
http://www.mvps.org/access/api/api0001.htm describes how to directly use the
Windows Common Dialog via its API, and does exactly what you describe. It
even has sample code for how to use it.

Larry Linson
Microsoft Access MVP

Thank you for the assist Larry. Just one more quick question, that I hope
you or others can answer.

How can I set the Dialog Box Title to a specific string of text.
 
Justin Busch said:
Thank you for the assist Larry. Just one more quick question, that I hope
you or others can answer.

How can I set the Dialog Box Title to a specific string of text.
 
Justin Busch said:
Thank you for the assist Larry. Just one more quick question, that I hope
you or others can answer.

How can I set the Dialog Box Title to a specific string of text.

The example at http://www.mvps.org/access/api/api0001.htm shows you how:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

sets the title to "Please select an input file..."

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)
 
Douglas J. Steele said:
The example at http://www.mvps.org/access/api/api0001.htm shows you how:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

sets the title to "Please select an input file..."
Thank you Doug,

That worked out perfectly.

I was originally trying based on the pop-up fields and resulted with this:
strOutputFileNameEnroll = ahtCommonFileOpenSave([OpenFile:=False,
Filter:=strFilter, Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_READONLY], , , ,
, , title)

Thank you all again!
 
Back
Top