Newataccess
Apr 21 2012, 09:13 AM
I"m using this code:
Me!PhotoPath = LaunchCD(Me)
To search the C drive for specific photos....
This works well in Access 2010, but I can't seem to get to work in earlier access versions, like 2003.
Is there another way, using, say, VBA, to do this. Or is there some other earlier version of LaunchCD(Me)?
Also, when building a table in AC 2010, one can choose "attachments" as one of the options for a control defintion, (as opposed to number, text, autonumber, etc)....
Is there something in earlier versions that does the same as attachments?
Thanks.
theDBguy
Apr 21 2012, 09:37 AM
Hi,
Are you using the 64-bit version of Access? Can you show us the code for LaunchCD()? Thanks.
Just my 2 cents...
Newataccess
Apr 21 2012, 09:40 AM
Actually, I found the LaunchCD code online....tried it, used it, it worked.
The Me!lPhotoPath = LaunchCD(Me) is the line I found and used.
Newataccess
Apr 21 2012, 09:43 AM
Actually, I should have said that I'm just tryin to find a way, in earlier versions of access, to use a command button
to search the c drive, then insert the c drive pathway for the file into a control on my form
Peter46
Apr 21 2012, 09:45 AM
Can't find a problem.
It works for me in A2010 and A2003 (provided you have added the Launchcd() code to your application.).
In this context LaunchCD is part of the common dialog API.
theDBguy
Apr 21 2012, 09:46 AM
QUOTE (Newataccess @ Apr 21 2012, 07:43 AM)

Actually, I should have said that I'm just tryin to find a way, in earlier versions of access, to use a command button
to search the c drive, then insert the c drive pathway for the file into a control on my form
I think I already gave you this link but here it is again. Will that do?
API: Call the standard Windows File Open/Save dialog boxJust my 2 cents...
Newataccess
Apr 21 2012, 09:49 AM
Do you mean add the Me!lPhotoPath = LaunchCD(Me) to the OnClick Event?
Newataccess
Apr 21 2012, 10:05 AM
Okay, I added this to a new module....
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.hwnd
sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"JPEG Files (*.JPG)" & Chr(0) & "*.JPG" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Select a file using the Common Dialog DLL"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1, OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
It works fine.....
It does insert the correct file pathway into the control.....
In access 2003, I'm trying to launch to that file using a hyperlink in the control. Is tha the correct way?
Thanks
Peter46
Apr 21 2012, 10:10 AM
I wouldn't like to comment on 'correct'.
What I usually do is (not use hyperlinks) and
Application.Followhyperlink me.textboxname
Newataccess
Apr 21 2012, 10:25 AM
Thanks, that works...
Appreciate all the help..
theDBguy
Apr 21 2012, 10:31 AM
QUOTE (Newataccess @ Apr 21 2012, 08:05 AM)

In access 2003, I'm trying to launch to that file using a hyperlink in the control. Is tha the correct way?
You could also use the ShellExecute() API from the same website:
API: Start an app with ShellExecuteJust my 2 cents...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.