473,474 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Is it possible to attach (VBA) code to a hyperlink field in an Access Table

33 New Member
Hi, I have an Access table containing 160 rows. Each row contains a hyperlink to an Excel file whose name is derived from the primary key of the record.

The Excel files initially do not exist but will be created by copying a master file.

Question is, can I attach code to the click event on each hyperlink so that I can determine whether the target file needs to be created by copying in the master file?

Many thanks in anticipation
Phil
Nov 3 '10 #1
2 4392
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi Phil. If you create a form and access the hyperlink field through a control on the form you will have access to the address contained in the hyperlink, and to the control's events - including On Enter, On Click, On Got Focus, On Lost Focus, and so on.

You'd need to do some testing to see which of the control's events, if any, is the most suitable for you, as it is possible to shift focus to the control in which you have the hyperlink without executing the hyperlink contained within it (for example, by tabbing into the field from another control).

the most likely candidate is probably the On Enter event, which is likely to occur before the hyperlink contained in the control is followed.

You can trigger the Hyperlink's Follow event from code, but of course you will have to have set up your file first before you do so. Whatever you do, you'll have to do it before the Follow event is triggered, because you can't intercept the Follow event itself as far as I know.

-Stewart
Nov 6 '10 #2
ADezii
8,834 Recognized Expert Expert
I'm not a hugh fan of Hyperlinks in general, so what I do is:
  1. Store the Absolute Path to a File in a TEXT Field within a Table.
  2. Have a Field (Text Box) on a Form Bound to this Field in the Table.
  3. Set the Forecolor to Blue and Underlined to True.
  4. In the Click() Event of the Text Box, you can insert Code that will Validate the Path to the File and either Open it as a Hyperlink, or provide an Error Message to the User, as in:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Hyper_Click()
    2.   If Dir$(Me![Hyper]) <> "" Then
    3.     Application.FollowHyperlink Me![Hyper], , True
    4.   Else
    5.     MsgBox "Cannot Navigate to Hyperlink!", vbExclamation, "Hyperlink Error"
    6.   End If
    7. End Sub
  5. The disadvantage to this Method is that you won't get the Itty Bitty Hand, but you can perform some special effects in the MouseMove() Event of the Control.
Nov 6 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dan Hicks | last post by:
Hi, I wrote this test code as part of a module I created for the Northwind database. However, I was only using this as a test platform. My goal was to write a program that would take records...
3
by: equalive | last post by:
Hi guys, I'm having problem locking a table in Ms Access using VB6 code. Actually I have 3 tables. Assume table names is A, B, C. Following is the process. 1. Open table A and update table...
1
by: rjs824 | last post by:
I am not a Programmer, but need some serious help with a syntax format for VBA in Access 2003. I need to update/copy the contents of a single record field to many records with the same field...
8
by: Chris Shelley | last post by:
I'd like to attach VBA code to a table the way i can with reports and forms .... I have not been able to figure out a way to do this .... Is this something that can be done ? or am I searching in...
1
by: Harnish | last post by:
Hey All! This is Harnish. I am extremely new to both VBA and this forum! Could anyone please point me to some sample code (VB) to export a table in MS Access to MySQL. Essentially my...
0
by: parth | last post by:
Is there a way to do it in VBA? Thanks. Parth
13
Dököll
by: Dököll | last post by:
Hiya Fans! By the time this afternoon ends I would have figured this out. I remember seeing a post or link somewhere about this (Googling thereafter)... Can we disable control + g in Access...
4
MattFitzgerald
by: MattFitzgerald | last post by:
I am using the below code to import a table when the code run I get a pop up box asking me for the password for the database I am importing from. Is it possible to put the password into my code so...
5
by: qwert1 | last post by:
I have 2 tables. table 1 looks like: Test1 Test2 Test3 0.6 0.1 0.5 0.4 0.4 0.3 0.2 0.8 0.5 table...
3
by: sarah2855 | last post by:
Hello All, I'm looking for the vb code that export an access table to specific worksheet in Excel. I tried to search see if this question was answered before here, but didn't find anything that...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.