MySQL Forums
Forum List  »  Microsoft Access

Re: Converting Hyperlink Fields from Access to MYSQL
Posted by: Sebastien Caisse
Date: January 11, 2006 05:28PM

Ok, I checked my code in a test sub and it works fine... I'm starting to wonder wether you'll have the same problem with my code too: check the object browser (Press F2 in the code window), type "FileDialog" to the left of the binoculors and click'm to look for it... If you don't find it it means that the FileDialog object can't be instantiated from this version of MS Access... and we need to find another solution (other then say... upgrading to 2003?)

[edit]
I'm looking into making something similar to the URL which you posted and use the Win32 API directly... This has the advantage that the client computer on which you run the software does not require to have the reference installed and I would personnaly like to remove this reference in my own applications :)

I'll post developments as it comes.

[edit 2]
I managed to use the code, it wasn't hard really. I exposed the GetOpenFileName function from the Win32 API to VB using the rather useful Visual Studio 6 API Text Viewer tool and updated the declarations to meet the Win2000/XP additional features (there's not much more but it's there, heh, although it means losing compatibility with 9x/ME/NT4, so if this is important just remove the last three lines of the OPENFILENAME Type).

Append this into a new module:

'''''''' Start append ''''''''
Public Enum OFN
OFN_ALLOWMULTISELECT = &H200
OFN_CREATEPROMPT = &H2000
OFN_ENABLEHOOK = &H20
OFN_ENABLETEMPLATE = &H40
OFN_ENABLETEMPLATEHANDLE = &H80
OFN_EXPLORER = &H80000 ' new look commdlg
OFN_EXTENSIONDIFFERENT = &H400
OFN_FILEMUSTEXIST = &H1000
OFN_HIDEREADONLY = &H4
OFN_LONGNAMES = &H200000 ' force long names for 3.x modules
OFN_NOCHANGEDIR = &H8
OFN_NODEREFERENCELINKS = &H100000
OFN_NOLONGNAMES = &H40000 ' force no long names for 4.x modules
OFN_NONETWORKBUTTON = &H20000
OFN_NOREADONLYRETURN = &H8000
OFN_NOTESTFILECREATE = &H10000
OFN_NOVALIDATE = &H100
OFN_OVERWRITEPROMPT = &H2
OFN_PATHMUSTEXIST = &H800
OFN_READONLY = &H1
OFN_SHAREAWARE = &H4000
OFN_SHAREFALLTHROUGH = 2
OFN_SHARENOWARN = 1
OFN_SHAREWARN = 0
OFN_SHOWHELP = &H10
End Enum

Public Enum OFN_EX
OFN_EX_NOPLACESBAR = &H1
End Enum

Public 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 OFN
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
pvReserved As Long
dwReserved As Long
FlagsEx As OFN_EX
End Type

Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
'''''''' End append ''''''''

Then use this to call it (in your event):

Private Sub btnTextHyperLink1Address_Click()

' Variables which define options you want in the option dialog
' Find more information about it here:
' http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxfunctions/getopenfilename.asp
Dim OFN As OPENFILENAME

With OFN
' Need to tell it what size it really is
.lStructSize = Len(OFN)

' Pre-assign memory for string
.lpstrFile = String(255, 0)

' Tell the string length
.nMaxFile = Len(.lpstrFile)
End With

' Call the function
If GetOpenFileName(OFN)
'
' OK! Get the selected filename from ofn.lpstrFile.
'

TextHyperlink1Address = ofn.lpstrFile

Else

'
' Put error handling here.
' Check CommDlgExtendedError reference for help, if you need to process
' this, I also converted the error codes and function definition to use it.
'

Err.Raise vbObjectError + 806115, "TextHyperlink1Address_Click", "There was an error in the file selection..."

End If

End Sub



Edited 4 time(s). Last edit at 01/11/2006 09:22PM by Sebastien Caisse.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Converting Hyperlink Fields from Access to MYSQL
3097
January 11, 2006 05:28PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.