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

drag and drop filepath 2

Status
Not open for further replies.

andygeorge

Technical User
Jun 5, 2002
11
GB
(Access 97)

Hi Guys,

I wonder if there's anyone out there who knows anything about this :

What I would like to do is allow the user to drag and drop a file from windows explorer - into a textbox on an Access form - which would make the filepath for this file appear. (rather than getting the user to type it all in!)

This would be extremely useful. I would much appreciate any tips on this.

cheers,

Andy

 
Not sure about that...
But the next best thing is to add the "Common Dialog” Box to your form. This is the familiar box you see anytime a program asks you to open a file.
They can then go find a file and you can use the .Filename to get the file name
ActiveXCtl1.Filename
I use it a lot.
You have to have Access 2000 or better.

In the design of the form click on the last button at the bottom. It looks like a hammer and wrench called More controls. Click this and a list of Active-X controls you can add to your form will show. Look for “Microsoft Common Dialog Box Version x”
It could be way down the list. Click the tiny black arrow at the bottom and it will scroll to let you view more.

Code to get the filename once they pick it

ActiveXCtl1.DialogTitle = "Find PDF Files" ‘Lets you put a title on the box
ActiveXCtl1.DefaultExt = “*.txt” ‘ set the default fiel type
Filter1 = DocType & " (" & Extention1 & ") |" & Extention1
ActiveXCtl1.Filter = “Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
ActiveXCtl1.InitDir = "C:\your folder"
ActiveXCtl1.Action = 1 ‘1= open file mode

If ActiveXCtl1.FileName = "" Then
GoTo cmd_AddDocToManual_Exit
Else
Me![textboxforfilename] = ActiveXCtl1.FileName
End If
DougP, MCP
 
Have a look at the Drag&Drop.zip file on my website. It does what you want it to, but it keeps crashing when you close it. Perhaps someone else could help! I can get it to work with A97, but not A2k. If you want the A97 version, let me know & I'll upload it.

Ben ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
thanks.

Doug,
So does the ACC97 version work as intended ?
(I am working with ACC97 so this would be the one for me).

Yes could you please upload this version.


cheers,

Andy

 
Sorry - my last posting was supposed to be directed at oharab...

Andy
 
The A97 does work as intended.
It has been added to the Drag&Drop.ZIP on my website.

Enjoy


B ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
cheers Ben this looks great.
Complicated stuff though - will take me a while to figure this one out!

Are you ok with me using this ?

Andy
 
The code is not mine. It is from Dev Ashish ( All I have done is produce the demo file, so feel free to do with it as you will. I have to admit to not fully understanding it myself, but I'm getting there!

B ----------------------------------
Ben O'Hara
Home: bpo@RobotParade.co.uk
Work: bo104@westyorkshire.pnn.police.uk
Web: ----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top