Browse button - Access 2002 v 2007 (1 Viewer)

htodd

New member
Local time
Today, 09:46
Joined
Nov 18, 2010
Messages
4
Can anyone explain why my Browse button worked ok in my database in Access v2002, but since I've been upgraded to Access v2007 the button no longer works?? The button enabled the user to search for a file, and once found provided a hyperlink in an additional text box field. The user was then able to click on the filename and open it from the text box field. Now I've been upgraded nothing works! I've no idea where to look, but feel that some references may be missing in Access 2007 - any ideas??
 

vbaInet

AWF VIP
Local time
Today, 17:46
Joined
Jan 22, 2010
Messages
26,374
Are you sure you've upgraded to 2007. I think you've simply opened the 2002 Access db in 2007.

If that's the case, create a new Access 2007 shell and import all the objects into it.

Re your problem, I think you've used a deprecated function to perform the search. I can't remember the name but can we see the code?
 

htodd

New member
Local time
Today, 09:46
Joined
Nov 18, 2010
Messages
4
>> I think you've simply opened the 2002 Access db in 2007..

Yes that's what my scenario is i.e. opened version 2002 db in version 2007. Funnily enough I get the same problem if I try to use the sample "Browse File/Directory" db as supplied by user "ghudson" in 2002 - not sure how to link to the thread from here as am new to this site. I can open all of the forms ok from ghudsons sample db and see the buttons etc, but when I click on them nothing happens. I'll try your import suggestion and see what happens..
 

vbaInet

AWF VIP
Local time
Today, 17:46
Joined
Jan 22, 2010
Messages
26,374
The import suggestion would only convert to 2007 so do it on a backup copy.

Maybe ghudson has an update to his code or there's something you're missing. Copy the url and paste here.
 

htodd

New member
Local time
Today, 09:46
Joined
Nov 18, 2010
Messages
4
ghudsons url = http://www.access-programmers.co.uk/forums/showthread.php?t=97787

I appear to be unable to do the import now because v2002 has been uninstalled from my pc by system administrator during installation of v2007.

Basically I have a form with two buttons on it:

Button 1 = Command button
Name = Browse
Caption = Browse...

"On click" code:
Private Sub Browse_Click()
Me!Text1 = LaunchCD(Me)
End Sub

Button 2 = Text box (unbound)
Name = ReqFile
"Is Hyperlink" = Yes

Module1 - code:
Option Compare Database

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


When I clicked on the Browse button in Access v2002 - all worked fine.

When I click on the Browse button in Access v2007 - the form acts if no code is available at all - I'm sure something is missing, but not sure what...
 

htodd

New member
Local time
Today, 09:46
Joined
Nov 18, 2010
Messages
4
Cracked it thanks!

Fiddling around with trust settings is not something I've done before but I've managed to sort it now - cheers and thanks for your help :)
 

Users who are viewing this thread

Top Bottom