importing data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to create a macro that will import data into my database. Each month
it will be a different file. Therefore, I would like to open a dialog box to
let the user select the file in the import process. Any help getting started
would be greatly appreciated. Thank you for the help.
 
Instead of the macro create a functio that will prompt the user to enter the
name
and then import the file with that name

Function ImportFileText()
Dim MyFileName As String
MyFileName = InputBox("Enter File Name:")
DoCmd.TransferText acImportDelim, , TableName, "c:\" & MyFileName & ".txt"

' change it to the file type you need, play with it to match your needs, and
if you still want a macro, then create one to run this function

End Function
 
If you want to allow the user to browse for the file instead of type in the
file name and path, you can create a browse window using the Common Dialogue
control or the Windows API call in VBA. This is more user-friendly, although
you may not find building the interface very programmer-friendly. Look at:

http://www.mvps.org/access/api/api0001.htm

Also search for comdlg32.dll in the Access Database Programming section of
this discussion group, where you will find a a rather lengthy discussion
thread that should give you some info on using that API call effectively.
 
Back
Top