logo
search
Others

How to Open a Hyperlink with a Microsoft Access Command Button

Maira MehtabMaira Mehtab Sep 27, 2026 869 views

Question details

The user needs to configure a command button on a Microsoft Access form to directly open a specific website, rather than relying on a standard WebLink control.

Product
Microsoft Access
Device & OS
not provided
Scenario
Customizing a database form where clicking a button triggers the default web browser to navigate to a designated URL.
Observed behavior
The intended outcome is to successfully launch a web browser and open the desired web address using the button's Click event.
Before you start

Ensure you have your Microsoft Access database open and the specific form loaded in Design View. You will need basic access to the VBA (Visual Basic for Applications) editor to add a single line of code.

Solution 1Recommended

Use the Application.FollowHyperlink Method in Access VBA

By adding the Application.FollowHyperlink method to the command button's On Click event, you can execute a script that opens any valid URL or file path.

Microsoft Access forms use VBA macros to handle user interactions like button clicks. The FollowHyperlink method is a built-in Access Application function that instructs the operating system to open the provided string (a website URL or a file path) using the system's default application.

1
Open the form in Design View

Right-click your target form in the Access navigation pane and select 'Design View'.

2
Access the Command Button Properties

Click the command button you want to configure. If the Property Sheet is not visible on the right, press F4 to open it.

3
Create an On Click Event Procedure

In the Property Sheet, navigate to the 'Event' tab. Find the 'On Click' property, click the drop-down arrow, and select '[Event Procedure]'.

4
Open the VBA Editor

Click the ellipsis (...) button next to the 'On Click' property to launch the Microsoft Visual Basic for Applications editor.

5
Insert the FollowHyperlink Code

In the code window, your cursor will be placed between 'Private Sub' and 'End Sub'. Type the following code: Application.FollowHyperlink "https://example.com" (replacing the URL with your desired website link).

6
Save and Test

Save your VBA code and close the editor. Switch your form back to 'Form View' and click the button to verify it opens the web browser.

Security Prompt: Depending on your MS Access security settings, clicking the button may display a security warning asking to confirm if you want to open the hyperlink. This is normal behavior for Access.
Free Microsoft Office alternative

Looking for a Lightweight Alternative to Microsoft Office?

While Microsoft Access handles complex database structuring, most everyday document, spreadsheet, and presentation tasks don't require heavy-duty database software. WPS Office provides a free, streamlined office suite experience that is completely compatible with core Microsoft Office formats.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
  2. 2. Install WPS Office: Run the downloaded file and follow the quick installation prompts to set up the software.
  3. 3. Start Working Instantly: Open your existing Word, Excel, or PowerPoint files in WPS Office without worrying about format conversion issues.
Fully compatible with Microsoft Word, Excel, and PowerPoint file formats.Free and lightweight, consuming minimal system resources compared to MS Office.Familiar ribbon user interface allowing for a seamless transition.All-in-one workspace featuring built-in PDF editing, conversion, and reading tools.
microsoft office alternative - wps office

Frequently Asked Questions

Can I use FollowHyperlink to open local files instead of websites?

Yes, the Application.FollowHyperlink method can open local files or network paths. Simply replace the website URL with the file's path, for example: Application.FollowHyperlink "C:\Users\Public\Documents\report.pdf".

How do I dynamically open a hyperlink based on a record's field value?

Instead of typing a static URL inside quotation marks, you can reference the field name containing the link in your form. Use the code: Application.FollowHyperlink Me.YourFieldName.Value.

Why does my command button return a runtime error when clicked?

A runtime error generally occurs if the provided URL is incorrectly formatted, the target website is unreachable, or if Microsoft Access macro security settings are configured to block VBA code execution.