Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Launching Web Brower either externally or within a form


Message #1 by "Lloyd Levine" <levinll@m...> on Fri, 27 Apr 2001 21:06:36
I'm using Access 97 and trying to find a way to either launch my web browser  to a specific 

web site either externally or from within a form. I know that I can do this in Access 2000 

using 

the Web Browser ActiveX component, but it doesn't work under 97.



Any ideas ?
Message #2 by John Fejsa <John.Fejsa@h...> on Mon, 30 Apr 2001 13:03:40 +1000
I'm not really sure which method you require so here are few.



1) You can use a Hyperlink Address and Hyperlink SubAddress Properties in 

Properties, Format to hardcode your command button or other object.



2) You can use VBA to create hyperlink address and hyperlink subaddress. 

The CreateHyperlink procedure in the following example sets the hyperlink 

properties for a command button, label, or image control to the address 

and subaddress values passed to the procedure. The address setting is an 

optional argument, because a hyperlink to an object in the current 

database uses only the subaddress setting, To try this example, create a 

form with two text box controls (txtAddress and txtSubAddress) and a 

command button (cmdFollowLink) and paste the following into the Declaration

s section of the form's module:



Option Compare Database

Option Explicit



Private Sub cmdFollowLink_Click() 'Attach this your command button or 

other object

	CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, Me!txtAddress

End Sub



Sub CreateHyperlink(ctlSelected As Control, strSubAddress As String, 

Optional strAddress As String)

	Dim hlk As Hyperlink

	Select Case ctlSelected.ControlType

		Case acLabel, acImage, acCommandButton

			Set hlk =3D ctlSelected.Hyperlink

			With hlk

				If Not IsMissing(strAddress) Then

					.Address =3D strAddress

				Else

					.Address =3D ""



End If

				.SubAddress =3D strSubAddress

				.Follow

				.Address =3D ""

				.SubAddress =3D ""

			End With

		Case Else

			MsgBox "The control '" & ctlSelected.Name & "' 

does not support hyperlinks."

	End Select

End Sub



3) you can use FollowHyperlink to get and set hyperlink address and goto 

it, for example.



Option Compare Database

Option Explicit



'Attach this to you object, ie., command button

Private Sub CallGetUserAddress_Click()

    If GetUserAddress =3D True Then ' Call the browser to open at specific 

internet address

        MsgBox "Successfully followed hyperlink."

    Else

        MsgBox "Could not follow hyperlink."

    End If

End Sub



'Save this in you modules, ie. form or global module

Function GetUserAddress() As Boolean

    Dim strInput As String



    On Error GoTo Error_GetUserAddress

    strInput =3D InputBox("Enter a valid address")

    Application.FollowHyperlink strInput, , True

    GetUserAddress =3D True



Exit_GetUserAddress:

    Exit Function



Error_GetUserAddress:

    MsgBox Err & ": " & Err.Description

    GetUserAddress =3D False

    Resume Exit_GetUserAddress

End Function



4) Use Access Help for addition mehods.



Hope this helps





_____________________________________



John Fejsa

Systems Analyst/Computer Programmer

Hunter Centre for Health Advancement

Locked Bag 10

WALLSEND NSW 2287

Phone: (02) 49246 336 Fax: (02) 49246 209





>>> levinll@m... 28/04/2001 7:06:36 >>>

I'm using Access 97 and trying to find a way to either launch my web 

browser  to a specific

web site either externally or from within a form. I know that I can do 

this in Access 2000

using

the Web Browser ActiveX component, but it doesn't work under 97.



Any ideas ?


  Return to Index