From: Jon Lewis on
What are you using to display the list? If it's the ListView control (as
opposed to the Access ListBox) then I would think you should be able to use
OLE Drag events to do this.

Have a look at this article:
http://www.devx.com/vb/Article/7864/1954
or try asking on the "microsoft.public.vb.general.discussion" group how you
drag from a VB ListView control to achieve this.

HTH


"roger" <roger(a)discussions.microsoft.com> wrote in message
news:94992A3D-6897-4A02-BE34-3C9CA1EAD369(a)microsoft.com...
> Well thanks, I guess. But I'm not willing to except "not possible." Not
> yet anyway.
>
> While I realize I cant do it simple Access controls, Drag and Drop is a
> core
> Windows technoloy. Access recieves drag and drop, it got to be in there
> someplace.
>
> And if not the Windows API, then how about OLE? Will an OLE control
> support
> drag and drop? and can I control it in VBA?
>
> Or how about a Custom control? (do we still call them ActiveX controls?)
> VB
> applets support drag and drop. Can I make a custom OCX control in VB and
> embed that on an Access form?
>
> There's got to be a way...
>
>
>
>
>
> "Douglas J. Steele" wrote:
>
>> I'm not sure it's possible.
>>
>> You may have to settle for copying to the clipboard and pasting into the
>> other program.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "roger" <roger(a)discussions.microsoft.com> wrote in message
>> news:EDAFA596-A73A-46FC-910F-ABF06C32E906(a)microsoft.com...
>> > I've read all about dragging files INTO Access forms, and dragging and
>> > dropping data between controls on Access forms. I need to do
>> > something
>> > different:
>> >
>> > MyApp has a subform with a list of files in a folder on the local HD.
>> > Currently I have buttons that opens the file using a Shell() command.
>> >
>> > The Users want to be able to drag files out of the list (on the subform
>> > in
>> > Access) and into other programs (like Notepad or Word), and have them
>> > open
>> > just like you dragged a file there out of windows explorer.
>> >
>> > I downloaded modules that "expose that Windows API" before, I'm
>> > assuming
>> > this will be of those, but I sure don't know how to write one.
>> >
>> > AHA TIA
>> > roger
>> >
>>
>>
>> .
>>


From: Jon Lewis on
Thought I'd have a bash at this myself, will this work for you?
(ListView0 is the ListView control from Windows Common Controls 6)

Option Compare Database
Option Explicit
Const vbCFFIles = 15
Const vbCFText = 1

Dim lCurX, lCurY As Single

Private Sub Form_Load()
Dim lstitem As ListItem
Set lstitem = ListView0.Object.ListItems.Add()
lstitem.Text = "Sample.txt"
lstitem.Key = "Fullpath\Sample.txt"
End Sub

Private Sub ListView0_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Long, ByVal y As Long)
lCurX = x
lCurY = y
End Sub

Private Sub ListView0_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal x As Long, ByVal y As Long)
If Button = 1 Then
ListView0.OLEDrag
End If
End Sub


Private Sub ListView0_OLEStartDrag(Data As Object, AllowedEffects As Long)
On Error GoTo ListView0_OLEStartDrag_Err
Dim oDrag As ListItem
Set oDrag = ListView0.HitTest(lCurX, lCurY)

If oDrag Is Nothing Then
AllowedEffects = ccOLEDropEffectNone
Else
AllowedEffects = ccOLEDropEffectCopy
Call Data.SetData(oDrag.Text, vbCFText)
Call Data.SetData(, vbCFFIles)
Call Data.Files.Add(oDrag.Key)
End If
Exit Sub
ListView0_OLEStartDrag_Exit:
Exit Sub
ListView0_OLEStartDrag_Err:
MsgBox Err.Number & ": " & Err.Description
Resume ListView0_OLEStartDrag_Exit
End Sub

HTH

"roger" <roger(a)discussions.microsoft.com> wrote in message
news:B5A2A13B-5B9A-4BA1-AC46-104321885436(a)microsoft.com...
> Hi Stuart, At least you're involved in "possiblity thinking."
>
> I've simulated drag and drop in Access before, but that isn't my goal. The
> goal here is to actually use Windows drag and drop, and not have to write
> custom procedures for every app the user could drop on. (just let windows
> do
> it)
>
> If it helps I'm using MSA 2007 which totally supports drag and drop, you
> can
> drag tables and queries out to excel or word, and drop excel ranges in as
> tables, so it IS in there.
>
> If there is really NO way to do it in a form, then I am thinking that a
> custom control is the answer. (I can't write one, but I would pay to have
> it
> written) just a transparent button with three events, click, double click
> and
> drag, and programmable value. With no other to drag data out of an Access
> app, maybe I could sell the control.
>
> Damn this is fustrating, from what I read, in .Net, this is as simple as
> setting .DragBehavoir = enabled.
>


From: roger on
Thanks Jon.
I'll look at this code.
I'm not useling a listbox, currently its a subform with text fields and
image controls. But there might be a Common Control I could put in there.

I'll let you know
roger


"Jon Lewis" wrote:

> Thought I'd have a bash at this myself, will this work for you?
> (ListView0 is the ListView control from Windows Common Controls 6)
>
> Option Compare Database
> Option Explicit
> Const vbCFFIles = 15
> Const vbCFText = 1
>
> Dim lCurX, lCurY As Single
>
> Private Sub Form_Load()
> Dim lstitem As ListItem
> Set lstitem = ListView0.Object.ListItems.Add()
> lstitem.Text = "Sample.txt"
> lstitem.Key = "Fullpath\Sample.txt"
> End Sub
>
> Private Sub ListView0_MouseDown(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Long, ByVal y As Long)
> lCurX = x
> lCurY = y
> End Sub
>
> Private Sub ListView0_MouseMove(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Long, ByVal y As Long)
> If Button = 1 Then
> ListView0.OLEDrag
> End If
> End Sub
>
>
> Private Sub ListView0_OLEStartDrag(Data As Object, AllowedEffects As Long)
> On Error GoTo ListView0_OLEStartDrag_Err
> Dim oDrag As ListItem
> Set oDrag = ListView0.HitTest(lCurX, lCurY)
>
> If oDrag Is Nothing Then
> AllowedEffects = ccOLEDropEffectNone
> Else
> AllowedEffects = ccOLEDropEffectCopy
> Call Data.SetData(oDrag.Text, vbCFText)
> Call Data.SetData(, vbCFFIles)
> Call Data.Files.Add(oDrag.Key)
> End If
> Exit Sub
> ListView0_OLEStartDrag_Exit:
> Exit Sub
> ListView0_OLEStartDrag_Err:
> MsgBox Err.Number & ": " & Err.Description
> Resume ListView0_OLEStartDrag_Exit
> End Sub
>
> HTH
>
> "roger" <roger(a)discussions.microsoft.com> wrote in message
> news:B5A2A13B-5B9A-4BA1-AC46-104321885436(a)microsoft.com...
> > Hi Stuart, At least you're involved in "possiblity thinking."
> >
> > I've simulated drag and drop in Access before, but that isn't my goal. The
> > goal here is to actually use Windows drag and drop, and not have to write
> > custom procedures for every app the user could drop on. (just let windows
> > do
> > it)
> >
> > If it helps I'm using MSA 2007 which totally supports drag and drop, you
> > can
> > drag tables and queries out to excel or word, and drop excel ranges in as
> > tables, so it IS in there.
> >
> > If there is really NO way to do it in a form, then I am thinking that a
> > custom control is the answer. (I can't write one, but I would pay to have
> > it
> > written) just a transparent button with three events, click, double click
> > and
> > drag, and programmable value. With no other to drag data out of an Access
> > app, maybe I could sell the control.
> >
> > Damn this is fustrating, from what I read, in .Net, this is as simple as
> > setting .DragBehavoir = enabled.
> >
>
>
> .
>
From: Douglas J. Steele on
Jon's suggestion of using the ListView control is a good one. Unfortunately,
you can't bind ListView controls, so depending on how your form currently is
used, you may find it more work than it's worth.

I think you'll find that's going to be your issue: the native Access
controls don't allow drag-and-drop, and using anything other than the native
Access controls means you won't be able to bind.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"roger" <roger(a)discussions.microsoft.com> wrote in message
news:6DE4CDCD-8B98-4BB3-9F5D-F18100E49843(a)microsoft.com...
> Thanks Jon.
> I'll look at this code.
> I'm not useling a listbox, currently its a subform with text fields and
> image controls. But there might be a Common Control I could put in
> there.
>
> I'll let you know
> roger
>
>
> "Jon Lewis" wrote:
>
>> Thought I'd have a bash at this myself, will this work for you?
>> (ListView0 is the ListView control from Windows Common Controls 6)
>>
>> Option Compare Database
>> Option Explicit
>> Const vbCFFIles = 15
>> Const vbCFText = 1
>>
>> Dim lCurX, lCurY As Single
>>
>> Private Sub Form_Load()
>> Dim lstitem As ListItem
>> Set lstitem = ListView0.Object.ListItems.Add()
>> lstitem.Text = "Sample.txt"
>> lstitem.Key = "Fullpath\Sample.txt"
>> End Sub
>>
>> Private Sub ListView0_MouseDown(ByVal Button As Integer, ByVal Shift As
>> Integer, ByVal x As Long, ByVal y As Long)
>> lCurX = x
>> lCurY = y
>> End Sub
>>
>> Private Sub ListView0_MouseMove(ByVal Button As Integer, ByVal Shift As
>> Integer, ByVal x As Long, ByVal y As Long)
>> If Button = 1 Then
>> ListView0.OLEDrag
>> End If
>> End Sub
>>
>>
>> Private Sub ListView0_OLEStartDrag(Data As Object, AllowedEffects As
>> Long)
>> On Error GoTo ListView0_OLEStartDrag_Err
>> Dim oDrag As ListItem
>> Set oDrag = ListView0.HitTest(lCurX, lCurY)
>>
>> If oDrag Is Nothing Then
>> AllowedEffects = ccOLEDropEffectNone
>> Else
>> AllowedEffects = ccOLEDropEffectCopy
>> Call Data.SetData(oDrag.Text, vbCFText)
>> Call Data.SetData(, vbCFFIles)
>> Call Data.Files.Add(oDrag.Key)
>> End If
>> Exit Sub
>> ListView0_OLEStartDrag_Exit:
>> Exit Sub
>> ListView0_OLEStartDrag_Err:
>> MsgBox Err.Number & ": " & Err.Description
>> Resume ListView0_OLEStartDrag_Exit
>> End Sub
>>
>> HTH
>>
>> "roger" <roger(a)discussions.microsoft.com> wrote in message
>> news:B5A2A13B-5B9A-4BA1-AC46-104321885436(a)microsoft.com...
>> > Hi Stuart, At least you're involved in "possiblity thinking."
>> >
>> > I've simulated drag and drop in Access before, but that isn't my goal.
>> > The
>> > goal here is to actually use Windows drag and drop, and not have to
>> > write
>> > custom procedures for every app the user could drop on. (just let
>> > windows
>> > do
>> > it)
>> >
>> > If it helps I'm using MSA 2007 which totally supports drag and drop,
>> > you
>> > can
>> > drag tables and queries out to excel or word, and drop excel ranges in
>> > as
>> > tables, so it IS in there.
>> >
>> > If there is really NO way to do it in a form, then I am thinking that a
>> > custom control is the answer. (I can't write one, but I would pay to
>> > have
>> > it
>> > written) just a transparent button with three events, click, double
>> > click
>> > and
>> > drag, and programmable value. With no other to drag data out of an
>> > Access
>> > app, maybe I could sell the control.
>> >
>> > Damn this is fustrating, from what I read, in .Net, this is as simple
>> > as
>> > setting .DragBehavoir = enabled.
>> >
>>
>>
>> .
>>


From: roger on
This WORKS!
Thanks.

Only thing is I'm not using a .Listview control. The article said that other
VB6 controls; picturebox, image, and textbox, all support OLE drag and drop.
But I don't have any of them in Access.

Am I missing something? Can I add those controls?

roger

"Jon Lewis" wrote:

> Thought I'd have a bash at this myself, will this work for you?
> (ListView0 is the ListView control from Windows Common Controls 6)
>
> Option Compare Database
> Option Explicit
> Const vbCFFIles = 15
> Const vbCFText = 1
>
> Dim lCurX, lCurY As Single
>
> Private Sub Form_Load()
> Dim lstitem As ListItem
> Set lstitem = ListView0.Object.ListItems.Add()
> lstitem.Text = "Sample.txt"
> lstitem.Key = "Fullpath\Sample.txt"
> End Sub
>
> Private Sub ListView0_MouseDown(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Long, ByVal y As Long)
> lCurX = x
> lCurY = y
> End Sub
>
> Private Sub ListView0_MouseMove(ByVal Button As Integer, ByVal Shift As
> Integer, ByVal x As Long, ByVal y As Long)
> If Button = 1 Then
> ListView0.OLEDrag
> End If
> End Sub
>
>
> Private Sub ListView0_OLEStartDrag(Data As Object, AllowedEffects As Long)
> On Error GoTo ListView0_OLEStartDrag_Err
> Dim oDrag As ListItem
> Set oDrag = ListView0.HitTest(lCurX, lCurY)
>
> If oDrag Is Nothing Then
> AllowedEffects = ccOLEDropEffectNone
> Else
> AllowedEffects = ccOLEDropEffectCopy
> Call Data.SetData(oDrag.Text, vbCFText)
> Call Data.SetData(, vbCFFIles)
> Call Data.Files.Add(oDrag.Key)
> End If
> Exit Sub
> ListView0_OLEStartDrag_Exit:
> Exit Sub
> ListView0_OLEStartDrag_Err:
> MsgBox Err.Number & ": " & Err.Description
> Resume ListView0_OLEStartDrag_Exit
> End Sub
>
> HTH
>
> "roger" <roger(a)discussions.microsoft.com> wrote in message
> news:B5A2A13B-5B9A-4BA1-AC46-104321885436(a)microsoft.com...
> > Hi Stuart, At least you're involved in "possiblity thinking."
> >
> > I've simulated drag and drop in Access before, but that isn't my goal. The
> > goal here is to actually use Windows drag and drop, and not have to write
> > custom procedures for every app the user could drop on. (just let windows
> > do
> > it)
> >
> > If it helps I'm using MSA 2007 which totally supports drag and drop, you
> > can
> > drag tables and queries out to excel or word, and drop excel ranges in as
> > tables, so it IS in there.
> >
> > If there is really NO way to do it in a form, then I am thinking that a
> > custom control is the answer. (I can't write one, but I would pay to have
> > it
> > written) just a transparent button with three events, click, double click
> > and
> > drag, and programmable value. With no other to drag data out of an Access
> > app, maybe I could sell the control.
> >
> > Damn this is fustrating, from what I read, in .Net, this is as simple as
> > setting .DragBehavoir = enabled.
> >
>
>
> .
>