Help with code to Import Files, numerous posts..

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I need this code revised so I can import excel files from any drive to my
"IDRa" table rather than opening it which is what it does now. This is from
Dev Ashish's example explorer97 datrabase I got off of MVP website. I am
not an access expert. I need very basic help with code below...Thanks
alot...Randy

Private Sub lbxFiles_DblClick(Cancel As Integer)
Dim varRet
Dim stPath As String

If mstPath = vbNullString Then
stPath = Left$(Me!lbxFolders, Len(Me!lbxFolders) - 1)
Else
stPath = mstPath & "\" & Me!lbxFolders
End If
varRet = fHandleFile(stPath & "\" & Me!lbxFiles, WIN_NORMAL)
End Sub
 
If I understand you correctly, you want to be able to browse for the file
instead of having the name and location of the file hard coded, is that
correct? If so, see this example:

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

This uses the Windows API to open the file open/save dialog box.
 
That is what I want. Iv'e pasted the code into a new module. Where do I go
from here. Thanks..I'm not a programmer, pretty basic
 
The code in the blue shaded area is what goes in a module. This code
included a procedure called TestIt. Go to the Debug window (Ctrl+G) and type
TestIt and press Enter. This will give you an example of what you're trying
to do. The procedure will return the name of the file you find in a message
box. Since you're wanting to find Excel files, you'll want to change one of
the strFilter lines in the TestIt procedure to

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.XLS")

You can comment out the other strFilter lines if you don't want them.
 
Thanks Wayne, I got a "Compile error, ambiguaous name detected" when I tried
your suggestion below...Rany
 
"Ambiguous Name Detected" would mean that you have 2 procedures with the
same name in your database. They must be unique within the database, not
just within the module. Also, a module name can't be the same as any
procedure in it or in any other module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top