Access

Form based Web Viewer

Ease of Use

Easy

Version tested with

2000, 2003 

Submitted by:

Brandtrock

Description:

This entry illustrates how to view webpages on a userform. The combobox at the top of the userform allows the user to select a site from the company data table. The web window allows normal surfing of the site selected. 

Discussion:

The ActiveX web browser control on the main form is directed to a user selected URL through the combobox selection at the top of the form. If a URL is included in the Company Data table, the form displays the URL. If no URL is associated with an entry, the Google search page is displayed. Additional or different websites are included by changing the information in the Company data table. 

Code:

instructions for use

			

Option Compare Database Option Explicit 'Code provided by Graham Thorpe of IT Learning Centre 'File "yoinked" from http://www.microsoft-accesssolutions.co.uk/downloads. 'Layout modifications have been made. Private Sub CompanyWebsite_AfterUpdate() On Error Resume Next ' If the user has entered an address (URL) in this control, ' attempt to navigate to the address. If Len(Me!CompanyWebsite) > 0 Then Me!wbbWebsite.Navigate Me!CompanyWebsite End If End Sub Private Sub Form_Current() 'Navigate to the current record's Web site 'If there's no URL stored in the field, then display Google search engine. If Len([CompanyWebsite]) > 0 Then wbbWebsite.Navigate URL:=[CompanyWebsite] Else wbbWebsite.Navigate URL:="www.google.com" End If End Sub Private Sub cboSearch_AfterUpdate() ' Find the record that matches the control. Dim rs As Object Set rs = Me.Recordset.Clone rs.FindFirst "[CompanyID] = " & Str(Me![cboSearch]) Me.Bookmark = rs.Bookmark 'Reset the combo box. Me.cboSearch = "" End Sub Private Sub Form_Open(Cancel As Integer) DoCmd.Maximize DoCmd.ShowToolbar "Form View", acToolbarNo DoCmd.ShowToolbar "Formatting (Form/Report)", acToolbarNo End Sub

How to use:

  1. 1. The best way to use this is to open the attached example.
  2. 2. When the Company Display form is launched go to Window and select VBAX WebForm : Database to switch to the database pane.
  3. 3. Select Tables.
  4. 4. Double Click tblCompany.
  5. 5. Edit the company names and url's as desired.
  6. 6. Save the file.
  7. 7. Close the file.
  8. 8. Now the database is set for your use.
  9. 9. Relaunch the file and surf to your heart's content.
 

Test the code:

  1. 1. Launch the example file.
  2. 2. The startup form will display.
  3. 3. Select a company name from the top box on the userform.
  4. 4. In the display window, you can surf to your heart's content.
 

Sample File:

VBAX WebviewerForm.zip 18.02KB 

Approved by mdmackillop


This entry has been viewed 392 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express