How to Open a Hyperlink with a Microsoft Access Command Button
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.
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.
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.
Right-click your target form in the Access navigation pane and select 'Design View'.
Click the command button you want to configure. If the Property Sheet is not visible on the right, press F4 to open it.
In the Property Sheet, navigate to the 'Event' tab. Find the 'On Click' property, click the drop-down arrow, and select '[Event Procedure]'.
Click the ellipsis (...) button next to the 'On Click' property to launch the Microsoft Visual Basic for Applications editor.
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).
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.
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. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install WPS Office: Run the downloaded file and follow the quick installation prompts to set up the software.
- 3. Start Working Instantly: Open your existing Word, Excel, or PowerPoint files in WPS Office without worrying about format conversion issues.

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.




