473,769 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Command button that locates a hyperlink in a table and then opens it

72 New Member
Hey Everybody, I have an URGENT REQUEST (I need a reply within 24 hours, or I lose my job) I need help writing vba code for a command button. I want this button to locate a hyperlink in a table (the hyperlinks have their own field) based on the record's name (the first field in the table). If the there is a hyperlink for the record, then I want it to be opened. If there is no hyperlink for the record, then I want a message box that states so.

My code so far is as follows:

Private Sub Command255_Clic k()
Dim x As Integer

If ([hyperlink exists]) Then
' Open hyperlink
Else
x = MsgBox("Sorry, link does not exist.", vbInformation, "No link found")
End If

End Sub

Obviously, my problems are that I cannot find a way to specify whether a link exists in the table, and I cannot find a way to locate the link and open it for the user.

I've created another field in the table that has a check box to indicate whether a link exists for each record or not. I don't know if that was needed or not.

Can anyone help me?
May 31 '07 #1
22 5261
Rabbit
12,516 Recognized Expert Moderator MVP
Hey Everybody, I have an URGENT REQUEST (I need a reply within 24 hours, or I lose my job) I need help writing vba code for a command button. I want this button to locate a hyperlink in a table (the hyperlinks have their own field) based on the record's name (the first field in the table). If the there is a hyperlink for the record, then I want it to be opened. If there is no hyperlink for the record, then I want a message box that states so.

My code so far is as follows:

Private Sub Command255_Clic k()
Dim x As Integer

If ([hyperlink exists]) Then
' Open hyperlink
Else
x = MsgBox("Sorry, link does not exist.", vbInformation, "No link found")
End If

End Sub

Obviously, my problems are that I cannot find a way to specify whether a link exists in the table, and I cannot find a way to locate the link and open it for the user.

I've created another field in the table that has a check box to indicate whether a link exists for each record or not. I don't know if that was needed or not.

Can anyone help me?
There's no context.

What is the recordsource of this form, is it the table with the hyperlinks?
What is the format of the hyperlinks?
When you click the button are you on the record you want to look up?
If not, how do you know which hyperlink you want to look up?
What tables are involved? What is the metadata of these tables?
If there's more than one table what is the primary key? The foreign key?
Is it a one to many relationship?
May 31 '07 #2
mforema
72 New Member
There's no context.

What is the recordsource of this form, is it the table with the hyperlinks?
What is the format of the hyperlinks?
When you click the button are you on the record you want to look up?
If not, how do you know which hyperlink you want to look up?
What tables are involved? What is the metadata of these tables?
If there's more than one table what is the primary key? The foreign key?
Is it a one to many relationship?
I'm sorry. I'm very new to Access and vba lingo. I have acquired an equipment database that is big and (apparently to me) complex.

There are 15 tables that the form is getting records from. The table with the hyperlinks is a new table that I created; I already related it to the "master list" table that the other tables are related to. They are all one to many relationships. The foreign key in the hyperlink table is the "Column Name" (the distillation columns at our plant). The "Column Name" is the primary key in the "master list" table. Again, it is a one to many relationship.

An example of one hyperlink is as follows:

\\jaxfsp01\grou ps\ProcEng\Dist illation Equipment Database\Gamma Ray Scans\O Column Preliminary Report.pdf

These hyperlinks are located in a directory on our company's G:\ drive, but they are not just .pdf files; there are also microsoft documents, such as .doc, .ppt, etc. The links work perfectly. I already checked them.

When I click the button, I am on the record that I want to look up.

I don't know what metadata means, but the tables have numbers, text, and hyperlinks in them.

I hope I clarified everything. Please let me know if you have anymore questions.

And thank you very much for helping me!
May 31 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
Try this:
Expand|Select|Wrap|Line Numbers
  1. FollowHyperlink DLookup("HyperlinkField", "HyperlinkTable", "ForeignKey = '" & Me.PrimaryKey & "'")
  2.  
You'll need to change HyperlinkField, HyperlinkTable, ForeignKey, PrimaryKey to reflect your names. They PK/FK is text right? If not, leave off the stuff with the single quotes.
May 31 '07 #4
mforema
72 New Member
Try this:
Expand|Select|Wrap|Line Numbers
  1. FollowHyperlink DLookup("HyperlinkField", "HyperlinkTable", "ForeignKey = '" & Me.PrimaryKey & "'")
  2.  
You'll need to change HyperlinkField, HyperlinkTable, ForeignKey, PrimaryKey to reflect your names. They PK/FK is text right? If not, leave off the stuff with the single quotes.
Thanks! But I keep getting an error message that says, "Method or Data Member Not Found," and then it highlights the Me.ID in the code below:

Private Sub Command255_Clic k()
FollowHyperlink DLookup("Gamma Scan Link", "Gamma Scans", "Column Name = '" & Me.ID & "'")
End Sub

(Of course, the FollowHyperlink code is on one line)

"Column Name" is the foreign key in the HyperlinkTable( aka, Gamma Scans), and ID is the primary key of the HyperlinkTable. What did I do wrong?
May 31 '07 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Thanks! But I keep getting an error message that says, "Method or Data Member Not Found," and then it highlights the Me.ID in the code below:

Private Sub Command255_Clic k()
FollowHyperlink DLookup("Gamma Scan Link", "Gamma Scans", "Column Name = '" & Me.ID & "'")
End Sub

(Of course, the FollowHyperlink code is on one line)

"Column Name" is the foreign key in the HyperlinkTable( aka, Gamma Scans), and ID is the primary key of the HyperlinkTable. What did I do wrong?
Usually that means you mispelled something. It's kind of hard to mispell ID though. What's the form's recordsource?
May 31 '07 #6
mforema
72 New Member
Usually that means you mispelled something. It's kind of hard to mispell ID though. What's the form's recordsource?
The Form's recordsource is "General Column Detail Query." So, I have an idea...maybe I haven't added the HyperlinkTable to the Query...how do I do that without screwing something else up?
May 31 '07 #7
Rabbit
12,516 Recognized Expert Moderator MVP
The Form's recordsource is "General Column Detail Query." So, I have an idea...maybe I haven't added the HyperlinkTable to the Query...how do I do that without screwing something else up?
You don't need to add the hyperlink table to the query, but you do need to add the ID to the query. What's the SQL of the query?
May 31 '07 #8
mforema
72 New Member
You don't need to add the hyperlink table to the query, but you do need to add the ID to the query. What's the SQL of the query?
SQL of Query:

SELECT MasterColumnLis t.[Column Name], MasterColumnLis t.Plant, [A - General Details].*, [B - Column Internals - Packing Details].*, [C - Column Internals - Distributor Details].*, [D - Stillpot Details].*, *
FROM MasterPlantList INNER JOIN ((((MasterColum nList INNER JOIN [A - General Details] ON MasterColumnLis t.[Column Name] = [A - General Details].Column) INNER JOIN [B - Column Internals - Packing Details] ON MasterColumnLis t.[Column Name] = [B - Column Internals - Packing Details].Column) INNER JOIN [C - Column Internals - Distributor Details] ON MasterColumnLis t.[Column Name] = [C - Column Internals - Distributor Details].Column) INNER JOIN [D - Stillpot Details] ON MasterColumnLis t.[Column Name] = [D - Stillpot Details].Column) ON MasterPlantList .Plant = MasterColumnLis t.Plant;

I know that's a lot, but I'm not sure what piece of it you need.
May 31 '07 #9
Rabbit
12,516 Recognized Expert Moderator MVP
Try:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command255_Click()
  2. FollowHyperlink DLookup("[Gamma Scan Link]", "[Gamma Scans]", "[Column Name] = '" & Me.Column_Name & "'")
  3. End Sub
  4.  
If you have spaces in your names you have to surround it using [ ]
May 31 '07 #10

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

Similar topics

2
2293
by: deko | last post by:
Is there a special syntax for hyperlinks in queries? I have a table of hyperlinked documents displayed in a subform datasheet. Clicking the hyperlink opens the document from the hard drive. I have an Autonumber field (Doc_ID) in the table that indexes the documents, but sometimes the same hyperlink can have different Doc_ID's, so I need a query to find the hyperlink in the table. For example: SELECT Entity_ID FROM tblDocuments WHERE...
5
2348
by: Maria João | last post by:
I have a table with one field that ia a hyperlink to a pdf file that opens a specific file. Since these files are very big, I would need to change the hyperlink path, so that I could send the hyperlink to one CDROM. I can do this part, but my problem ist that this DataBase is distributed in several machines in several places (not connected) and in each machine the CDROM drive have it's own letter (D: or E: ...). But I still have...
6
1385
by: Mark R | last post by:
Hi Guru's, I have a frontend application where my boss wants to when people are using the database. I have a form which OnOpen, inserts the username, network login and date/time it was opened to a table. I have created a 'Close' button which when clicked, updates the 'Logged_out' time and then quits the application. My problem is that when users click on the cross (top right corner) to close the database, this time is not logged. Is...
2
1782
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a table called states. I have 2 forms. On form 1 is the 50 states in textboxes created with a loop. I want to have those 50 or 45 or whatever amount of states have a hyperlink. Once you click the hyperlink it will take the stateId from the click event and use the Get method to send it to the next page. Page 2 will simply use the browswer get method to show information based on that stateid. So my...
2
5217
by: emc_cos | last post by:
I have a very nice parent child relationship happening between a main form and 8 subforms. The main form is the data entry point for a table that holds textual data like names, notes and the like. It also holds the primary key which is an alpha-numeric file designation. The subforms are the data entry point for another table that holds numeric values for time spent on tasks.
8
4799
by: jmarcrum | last post by:
Hello all, i have a continuous form that displays about 1000 records and opens when I click a button. When the form opens, the user has the option of checking a checkbox that is located beside each record. The checkbox is labeled "Move" (for moving multiple records at a time to another year). Of course, the checkbox is set as a control "moveRecord" on a table that the query is pulling from. So if the user checks one record, then clicks to...
16
2734
by: Steve | last post by:
I am working on a database that has a main menu, many sub-menus and some sub-sub-menus. They are all forms that have numerous command buttons on them to open forms and reports in the database. The database has hundreds of forms and reports. I was asked to go through all the menu forms and determine if all the buttons worked, if there were any problems when either the form or report opened and to come up with a list of the forms and reports...
14
22184
by: alnino | last post by:
Hi, I have a command button on a form that the user can use to browse to a file and the user can select that file and a hyperlink to that file is stored in a txtfield for that record. I then have a command button that a user can click to open and view the associated file. This all works fine. BUT: I would like the command button that allows the user to view the file to be hidden if no hyperlink was added. In other words the txtfield...
1
6263
by: alnino | last post by:
Hi, On a form I have a command button that allows a user to browse for a file (PDF, Word, etc…). This command button then stores a hyperlink to the file within an associated txtfield in the table. The VB to browse for the file is as follows Private Sub CmdBuildingAdd_Click() Me!txtSelectedFile = BrowseFiles()
0
9420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10205
Oralloy
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...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9851
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 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...
0
8863
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, 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...
0
5293
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...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
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
3
2811
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 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...

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.