Creating links to files on a form.

S

sheetsumon

I would like to use a listbox on a form to organize links to specific files.
This seems like a common enough thing to do (right guys?), but for the user
who's entering data, I don't want them to have to type in the full path of
the file's location, since it will take too much time.

So, I want to implement a drag-and-drop method. I know the AddressOf
operator can be used to do this, but I don't I don't completely understand
the concept of function callbacks and the only source I can find to help is:
http://www.mvps.org/access/api/api0032.htm

Since I'm using Access 2003, I've taken out the "AddrOf" fuction and replaced
it with "AddressOf," but I still can't get it to work.

I find it hard to believe that Access can't do this type of thing. I'm not
an expert VBA coder, so I'm struggling here & any help would be appreciated,
even if you can't give me advice on AddressOf.

My ultimate goal is to be able to search text strings from a master table and
be able to open files that go along with the text. Maybe I should use
another database program to handle this?
 
D

Douglas J. Steele

The syntax for AddressOf is slightly different than for AddrOf.

Rather than

lpPrevWndProc = apiSetWindowLong(Hwnd, _
GWL_WNDPROC, _
AddrOf(strFunction))

use

lpPrevWndProc = apiSetWindowLong(Hwnd, _
GWL_WNDPROC, _
AddressOf strFunction)

However, when I went to try the code just now, doing that did raise an
error.

I solved the problem by using

lpPrevWndProc = apiSetWindowLong(Hwnd, _
GWL_WNDPROC, _
AddressOf sDragDrop)

That means you can change the declaration of sHook to simply

Sub sHook(Hwnd As Long)

and the code in Form_Open to

Call sHook(Me.Hwnd)

Is there some reason, though, you don't simply use the File Open dialog
illustrated in http://www.mvps.org/access/api/api0001?
 
S

sheetsumon via AccessMonster.com

Thank you for your response Douglas. It's the best advice I've received.
Unfortunately, I already tried this. All it does is freeze Access and cause
the program to stop responding. It's probably the way I have my form set up.
I'm going to try to moving the Call sHook(Me.Hwnd) to the form's Load dialog
instead. If that doesn't work, I'll try to disect other parts of Dev Avish's
code. If I have questions, I'll let you know.

Thank you again for your help, and I appreciate the extra link.

Jon

The syntax for AddressOf is slightly different than for AddrOf.

Rather than

lpPrevWndProc = apiSetWindowLong(Hwnd, _
GWL_WNDPROC, _
AddrOf(strFunction))

use

lpPrevWndProc = apiSetWindowLong(Hwnd, _
GWL_WNDPROC, _
AddressOf strFunction)

However, when I went to try the code just now, doing that did raise an
error.

I solved the problem by using

lpPrevWndProc = apiSetWindowLong(Hwnd, _
GWL_WNDPROC, _
AddressOf sDragDrop)

That means you can change the declaration of sHook to simply

Sub sHook(Hwnd As Long)

and the code in Form_Open to

Call sHook(Me.Hwnd)

Is there some reason, though, you don't simply use the File Open dialog
illustrated in http://www.mvps.org/access/api/api0001?
I would like to use a listbox on a form to organize links to specific
files.
[quoted text clipped - 23 lines]
be able to open files that go along with the text. Maybe I should use
another database program to handle this?
 

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

Top