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!

ActiveX control for searching drives?

Status
Not open for further replies.

asenft

Programmer
Apr 24, 2001
52
US
Is there a way in Access 2000 either with an ActiveX control or something else, that i can pop up a window that will let the user pick a file on their system? I want to use this with some FTP functionality i am building. Any help would be great! Thanks.

Aaron
 
ActiveX common dialog control...

Here is the code and process for installing it. I got this from Tek-Tips a few months ago.

This example uses the Microsoft ActiveX control. The Access Developers handbook has another example.

1) On your form, add a common dialog control
(Insert ¦ ActiveX Control) (Microsoft common dialog control, version 5)
2) Name the control "cdlgOpen"
3) Add a button
4) Name the button "cmdBrowse"
5) Optional: I use either a private or public constant for my default path if you want one.

In General Declaration Section of form (private) or module (public):

Private Const EXISTINGFILE As String = "C:\My Documents\Zips\tasks.xls"
Private Const EXISTINGDIR AS String = "C:\MyDocuments\"

5) Copy and paste the following code on the Click Event of the button (minus the Private & End Sub lines).

==========
Private Sub cmdBrowse_Click()
Dim strNewFile As String

On Error GoTo Browse_Err
With Me.cdlgOpen
'You should only use one of the next two lines if you want to open to either a default file or folder
.filename = EXISTINGFILE 'Comment out if you don't want to open to a default file
'.initdir = ESIXTINGDIR 'Comment out if you don't want to open to a default folder
.CancelError = True
.Filter = "Excel Files (*.xls)¦*.xls¦" 'Can change (i.e. "Word Files (*.doc)¦*.doc¦") or ("All Files (*.*)¦*.*¦") see help for other examples
.ShowOpen ' Can use showSave for saving file, same principle
strNewFile = .filename
End With

Browse_Exit:
Exit Sub

Browse_Err:
If Err.Number = 32755 Then
Resume Browse_Exit
Else
MsgBox Err.Number & ": " & Err.Description
Resume Browse_Exit
End If
End Sub
==========

6) Now your variable strFile will represent your file and you can do whatever you want with it at that point.

If your default paths have the possibility of changing, you might consider putting them into a table or .ini file and retrieving them. This will allow you to change the path without having to adjust your code.

Hope this helps.

ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
Great, that worked awesome! Now i have an additional question. I used an ActiveX control that isnt available on the other computer i am testing on. Is there some way i can install it or get it from somewhere. The one i am trying to use is the Microsoft Internet Transfer ActiveX control.

-Aaron
 
That I am not sure of. You may want to do an Advanced Search on the Access forums for your ActiveX control and see what comes up. There is so much stuff already archived out here you would be amazed. I find stuff without asking a question.

ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top