Hello,
I have a problem with hyperlink.
I have a text box that contains link to the document. I enter the link by clicking on the button "add link". When I add link, the windows browser opens and i can search for exact document. But when I save the path in the Link text box, the link doent work. It is stored in News table and I changed it for hyperlink but still doesnt work. I noticed that when I am saving the path, it saves me the path as a link name that is shown in the text box, but the hyperlink path is empty.
How to make it works?
I would be grateful for help.
Greets
Greg
Nov 14 '07
15 37912 The following code, placed in the Click() Event of a Command Button named cmdPopulateHype rlink will:- Open a File Dialog Box, and allow you to select only 1 File of any type.
- Allow you to customize the Button and Dialog Title Captions within the File Dialog Box.
- Write the Hyperlink Caption and Address (both are required) to the Link Text Box on the Current Form. The Control Source for this Link Text Box is the [Link] Field.
- The Record Source for the Form is the Table News.
- The code has been thoroughly tested and is fully functional. I inserted Comments where I thought they may be needed.
- Any questions, feel free to ask.
-
Private Sub cmdPopulateHyperlink_Click()
-
'First, set a Reference to the Microsoft Office XX.X Object Library
-
-
Dim strButtonCaption As String, strDialogTitle As String
-
Dim strHyperlinkFile As String
-
-
'Define your own Captions if necessary
-
strButtonCaption = "Save Hyperlink"
-
strDialogTitle = "Select File to Create Hyperlink to"
-
-
With Application.FileDialog(msoFileDialogFilePicker)
-
With .Filters
-
.Clear
-
.Add "All Files", "*.*" 'Allow ALL File types
-
End With
-
'The Show Method returns True if 1 or more files are selected
-
.AllowMultiSelect = False 'Critical Line
-
.FilterIndex = 1 'Database files
-
.ButtonName = strButtonCaption
-
.InitialFileName = vbNullString
-
.InitialView = msoFileDialogViewDetails 'Detailed View
-
.Title = strDialogTitle
-
If .Show Then
-
For Each varItem In .SelectedItems 'There will only be 1
-
'Caption and Address of Hyperlink will be the same (Caption#Address)
-
strHyperlinkFile = varItem & "#" & varItem
-
Me![Link] = strHyperlinkFile
-
Next varItem
-
End If
-
End With
-
End Sub
-
Thank you very much for help. Now it is more clear for me how it works.
However i have a problem while clicking the button:
Compile error: Method or data member not found.
I pasted that code in VB in On click option. My button name is cmdPopulateHype rlink. And the other decribed option are the same. So i dont know what to do to work it out.
I also put references for Microsoft Office 12.0 Object Library
I dont know if its tell you sth but all the time i click button it shows me that error and then in the line : With Application.Fil eDialog(msoFile DialogFilePicke r), the work FileDialog is selected (not in yellow like in the beggining but in blue, like selecting for copying). I know that maybe its sth simple and i have really stupid remark, but as i said in the beggining, this is my beggining with VB...
greets
Greg
ADezii 8,834
Recognized Expert Expert
Thank you very much for help. Now it is more clear for me how it works.
However i have a problem while clicking the button:
Compile error: Method or data member not found.
I pasted that code in VB in On click option. My button name is cmdPopulateHype rlink. And the other decribed option are the same. So i dont know what to do to work it out.
I also put references for Microsoft Office 12.0 Object Library
I dont know if its tell you sth but all the time i click button it shows me that error and then in the line : With Application.Fil eDialog(msoFile DialogFilePicke r), the work FileDialog is selected (not in yellow like in the beggining but in blue, like selecting for copying). I know that maybe its sth simple and i have really stupid remark, but as i said in the beggining, this is my beggining with VB...
greets
Greg
Just for verification, what Version of Access are you using?
Just for verification, what Version of Access are you using?
I am using: MS Access 2000
I am using: MS Access 2000
If it helps, before i was using module code for file browser like this (but it saved me only display text, not hyperlink): -
'.=========================================================================
-
'.Browse Files Module
-
'.Copyright 1999 Tribble Software. All rights reserved.
-
'.Phone : (616) 455-2055
-
'.E-mail : carltribble@earthlink.net
-
'.=========================================================================
-
' DO NOT DELETE THE COMMENTS ABOVE. All other comments in this module
-
' may be deleted from production code, but lines above must remain.
-
'--------------------------------------------------------------------------
-
'.Description : This module calls directly into comdlg32.dll to allow user
-
'. to select a filename using the Windows Common Dialog. The
-
'. user may browse for a file, or enter a file name directly.
-
'.Written By : Carl Tribble
-
'.Date Created : 04/05/1999 09:56:31 AM
-
'.Rev. History :
-
' Comments : Normally, to use the Common Dialog you need to physically
-
' place the ActiveX control onto a form and then use code
-
' behind the form to implement its functionality. This
-
' module allows you to incorporate the functionality of the
-
' File Open/Save part of the Common Dialog without the
-
' ActiveX control itself. This module is completely self-
-
' contained. Simply copy it into your database to use it.
-
'.-------------------------------------------------------------------------
-
'.
-
' ADDITIONAL NOTES:
-
'
-
' This module only provides the Open/Save file dialog, not the other
-
' CommonDialog interfaces (ColorChooser, Help, PrintDialog, etc.)
-
'
-
' If you want your user to browse for folder names (paths) you must use
-
' the module basBrowseFolders instead.
-
'
-
' TO STREAMLINE this module for production programs, you should remove:
-
' 1) Unnecessary comments
-
' 2) Flag Constants which you do not intend to use.
-
' 3) The test procedure tsGetFileFromUserTest
-
'
-
'--------------------------------------------------------------------------
-
'
-
' INSTRUCTIONS:
-
'
-
' ( For a working example, open the Debug window )
-
' ( and enter tsGetFileFromUserTest. )
-
'
-
'.All the arguments for the function are optional. You may call it with no
-
'.arguments whatsoever and simply assign its return value to a variable of
-
'.the Variant type. For example:
-
'.
-
'. varFileName = tsGetFileFromUser()
-
'.
-
'.The function will return:
-
'. the full path and filename selected or entered by the user, or
-
'. Null if an error occurs or if the user presses Cancel.
-
'.
-
'.Optional arguments may include any of the following:
-
'. rlngFlags : one or more of the tscFN* constants (declared below)
-
'. Combine multiple constants like this:
-
'. tscFNHideReadOnly Or tscFNFileMustExist
-
'. strInitialDir : the directory to display when dialog opens
-
'. strFilter : a string containing any filters you want to use. Each
-
'. part must be separated by the vbNullChar. -example below
-
'. lngFilterIndex: a 1-based index indicating which filter to start with.
-
'. strDefaultExt : Extension to use if user does not enter one.
-
'. strFileName : Default File to display in the File Name text box.
-
'. strDialogTitle: Caption to display in the dialog's title bar.
-
'. fOpenFile : Boolean-True for the Open dialog, False for Save dialog.
-
'
-
' FILTER EXAMPLE: The filter must be a string containing two parts for each
-
' filter. The first part is the Description, it is what the user will see
-
' in the Files of Type box, e.g. "Text Files (*.txt)". The second part is
-
' the actual filter, e.g. "*.txt". Each part and each filter must be
-
' separated by the vbNullChar. For example, to provide two filters, one for
-
' *.mdb files, and one for all files, use a statement like this:
-
'
-
' strFilter = "Access (*.mdb)" & vbNullChar & "*.mdb" _
-
' & vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
-
'
-
' Then pass your strFilter variable as the strFilter argument for the call
-
' to tsGetFileFromUser()
-
'
-
'.--------------------------------------------------------------------------
-
'.
-
-
Private Declare Function ts_apiGetOpenFileName Lib "comdlg32.dll" _
-
Alias "GetOpenFileNameA" (tsFN As tsFileName) As Boolean
-
-
Private Declare Function ts_apiGetSaveFileName Lib "comdlg32.dll" _
-
Alias "GetSaveFileNameA" (tsFN As tsFileName) As Boolean
-
-
Private Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
-
-
Private Type tsFileName
-
lStructSize As Long
-
hwndOwner As Long
-
hInstance As Long
-
strFilter As String
-
strCustomFilter As String
-
nMaxCustFilter As Long
-
nFilterIndex As Long
-
strFile As String
-
nMaxFile As Long
-
strFileTitle As String
-
nMaxFileTitle As Long
-
strInitialDir As String
-
strTitle As String
-
Flags As Long
-
nFileOffset As Integer
-
nFileExtension As Integer
-
strDefExt As String
-
lCustData As Long
-
lpfnHook As Long
-
lpTemplateName As String
-
End Type
-
-
' Flag Constants
-
Public Const tscFNAllowMultiSelect = &H200
-
Public Const tscFNCreatePrompt = &H2000
-
Public Const tscFNExplorer = &H80000
-
Public Const tscFNExtensionDifferent = &H400
-
Public Const tscFNFileMustExist = &H1000
-
Public Const tscFNPathMustExist = &H800
-
Public Const tscFNNoValidate = &H100
-
Public Const tscFNHelpButton = &H10
-
Public Const tscFNHideReadOnly = &H4
-
Public Const tscFNLongNames = &H200000
-
Public Const tscFNNoLongNames = &H40000
-
Public Const tscFNNoChangeDir = &H8
-
Public Const tscFNReadOnly = &H1
-
Public Const tscFNOverwritePrompt = &H2
-
Public Const tscFNShareAware = &H4000
-
Public Const tscFNNoReadOnlyReturn = &H8000
-
Public Const tscFNNoDereferenceLinks = &H100000
-
-
Public Function tsGetFileFromUser( _
-
Optional ByRef rlngflags As Long = 0&, _
-
Optional ByVal strInitialDir As String = "", _
-
Optional ByVal strFilter As String = "All Files (*.*)" & vbNullChar & "*.*", _
-
Optional ByVal lngFilterIndex As Long = 1, _
-
Optional ByVal strDefaultExt As String = "", _
-
Optional ByVal strFileName As String = "", _
-
Optional ByVal strDialogTitle As String = "", _
-
Optional ByVal fOpenFile As Boolean = True) As Variant
-
-
On Error GoTo tsGetFileFromUser_Err
-
Dim tsFN As tsFileName
-
Dim strFileTitle As String
-
Dim fResult As Boolean
-
-
' Allocate string space for the returned strings.
-
strFileName = Left(strFileName & String(256, 0), 256)
-
strFileTitle = String(256, 0)
-
-
' Set up the data structure before you call the function
-
With tsFN
-
.lStructSize = Len(tsFN)
-
.hwndOwner = Application.hWndAccessApp
-
.strFilter = strFilter
-
.nFilterIndex = lngFilterIndex
-
.strFile = strFileName
-
.nMaxFile = Len(strFileName)
-
.strFileTitle = strFileTitle
-
.nMaxFileTitle = Len(strFileTitle)
-
.strTitle = strDialogTitle
-
.Flags = rlngflags
-
.strDefExt = strDefaultExt
-
.strInitialDir = strInitialDir
-
.hInstance = 0
-
.strCustomFilter = String(255, 0)
-
.nMaxCustFilter = 255
-
.lpfnHook = 0
-
End With
-
-
' Call the function in the windows API
-
If fOpenFile Then
-
fResult = ts_apiGetOpenFileName(tsFN)
-
Else
-
fResult = ts_apiGetSaveFileName(tsFN)
-
End If
-
-
' If the function call was successful, return the FileName chosen
-
' by the user. Otherwise return null. Note, the CancelError property
-
' used by the ActiveX Common Dialog control is not needed. If the
-
' user presses Cancel, this function will return Null.
-
If fResult Then
-
rlngflags = tsFN.Flags
-
tsGetFileFromUser = tsTrimNull(tsFN.strFile)
-
Else
-
tsGetFileFromUser = Null
-
End If
-
-
tsGetFileFromUser_End:
-
On Error GoTo 0
-
Exit Function
-
-
tsGetFileFromUser_Err:
-
Beep
-
MsgBox Err.Description, , "Error: " & Err.Number _
-
& " in function basBrowseFiles.tsGetFileFromUser"
-
Resume tsGetFileFromUser_End
-
-
End Function
-
-
' Trim Nulls from a string returned by an API call.
-
-
Private Function tsTrimNull(ByVal strItem As String) As String
-
-
On Error GoTo tsTrimNull_Err
-
Dim I As Integer
-
-
I = InStr(strItem, vbNullChar)
-
If I > 0 Then
-
tsTrimNull = Left(strItem, I - 1)
-
Else
-
tsTrimNull = strItem
-
End If
-
-
tsTrimNull_End:
-
On Error GoTo 0
-
Exit Function
-
-
tsTrimNull_Err:
-
Beep
-
MsgBox Err.Description, , "Error: " & Err.Number _
-
& " in function basBrowseFiles.tsTrimNull"
-
Resume tsTrimNull_End
-
-
End Function
Everything is ok now.
Inspired by your code, i have simply copied "#" & into following line:
Me![Link] = "#" & varFileName
and now its working :)
it was so easy solution that now i am embaressed by posting that question :)
Thx very much for help and inspiration :)
Greg
ADezii 8,834
Recognized Expert Expert
Everything is ok now.
Inspired by your code, i have simply copied "#" & into following line:
Me![Link] = "#" & varFileName
and now its working :)
it was so easy solution that now i am embaressed by posting that question :)
Thx very much for help and inspiration :)
Greg
You are quite welcome. Many Users are confused when it comes to programmaticall y adding Hyperlinks to a Form Field Bound to a HyperLink Data Type. As a matter of fact, this will probably be the Subject of the next Tip of the Week.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tero Partanen |
last post by:
Hello!
I'm writing about a rather peculiar problem I'm having with
Access2000.
I have a table in which I have created one hyperlink-type field. I
have given the field a default value which is an email-address. The
default value is (for example): "mailto:mymail@here.com".
Access2000 correctly inserts that information into the field everytime
|
by: Paul |
last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like
00001,000002, ect. Just wondering how to get the text value of the cell as
tempstring = datagrid.Items(rownumber).Cells.Item(column number).Text
returns a blank string. It seems to work ok for the other columns that are
just regular datagrid columns, not hyperlink types.
Thanks.
--
Paul G
Software engineer.
|
by: Joe |
last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first
column contains hyperlinks. When a user clicks one of these hyperlinks, he
will navigate to another aspx page (referred to here as page_2). I need to
cache the value of the link's text (hyperlink.text property) so that I can
use it in the page_load event of page_2.
I've thought of using a hidden field and then calling
Request.Form("hdnClickedLinkText") in the...
|
by: Keith Wilby |
last post by:
I have a personnel database with a hyperlink field which contains the path
to a mugshot. I was thinking of combining the hyperlink field with the
surname field by putting the surname in the "Display Text" of the hyperlink.
I have 200 or so existing records - can this be done either with code or in
a query? I'm not sure of the syntax to use to reference the "Display Text"
property (if it can be done at all).
Many thanks.
Keith.
|
by: tshad |
last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the
problem.
Apparently, it doesn't figure out the path correctly. It uses the path of
the file it is in, even if it is a control.
I have 2 files "displayCompanyJobs.aspx" and "displayCompanyOverview.aspx"
which are in both the folder "/jobseeker/" and "/employer/".
I have a user control "displayCompanyJobs.ascx" that is in my /applicant/
| |
by: ADezii |
last post by:
Recently, there have been several questions and much confusion concerning the Topic of Hyperlinks. Specifically, Users wanted to know how to retrieve a File Name from a FileDialog Box, copy the Name to a Bound Text Box on a Form, and save the Hyperlink to the underlying Table. The code demos below will do just that: retrieve the Absolute Path of of File from a FileDialog Box, use the Base Name (no extension) as the Display Text for the...
|
by: k lee |
last post by:
I want to create a linkButton to activate my hyperlink which will open a new page in a new window. I would like to know how to code the code of activate the hyperlink which I wish to place it in the 'onclick' event of the linkButton.
|
by: suvaline |
last post by:
I dont know much about VBA, but maybe somebody can help me ;)
I have this kind of SUB ..
Sub kama2()
Worksheets("kama").Activate
Range("A51").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Application.WindowState = xlNormal
Start_Timer
End Sub
... and question ...
|
by: sierra7 |
last post by:
I'm trying to create a form where a user enters a document reference number and then clicks a command button to add a hyperlink to the document, via a file picker.
Thanks to Adezii's excellent article http://bytes.com/topic/access/answers/725778-inserting-hyperlink-into-table I can manage to create a hyperlink to the document and store it in the table, but it is the full hyperlink path not the reference number of the document that is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |