Creating a button that when clicked opens a website page for the current record.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a contacts formwith a combo box at the top. When you type in the name of a company in the combo box, assuming they are in the database, their details appear in the fields underneath. Included in the list of company details is a field for website address. I want to create a button that when clicked on open internet explorer and automatically opens their website address. I also need a button that will paste/send the address details into MS Word so that a letter can be typed to that company. Can anyone help? Thanks in advance.
 
Hi!

I think I can help you out with one of these tasks!

Instead of a cmd to open the website you could use a hyperlink field storing
the address to the website. If so you only have to click on the hyperlink
text and your web reader will open up searching for the web address!

If this is what you´r after I don´t know but it sure is possible!

// Niklas



Richard Horne said:
Hi,

I have a contacts formwith a combo box at the top. When you type in the
name of a company in the combo box, assuming they are in the database, their
details appear in the fields underneath. Included in the list of company
details is a field for website address. I want to create a button that when
clicked on open internet explorer and automatically opens their website
address. I also need a button that will paste/send the address details into
MS Word so that a letter can be typed to that company. Can anyone help?
Thanks in advance.
 
Hi Niklas, yes that method would work but ideally I stil want to have a button to open the website, it's just a bit more intuitive to click a button. Also there will be buttons to open other details about each customer so therefore I want to keep the consistency.
 
Yes, I agree with you. Concistency is importent. It´s far to easy to confuse
the user anyway! Unfortunately I don´t have any solution for you at this
moment. I´ll take a closer look at this later on though. Right now I´m at
work and I do not work with Access here, unfortunately!

// Niklas

Richard Horne said:
Hi Niklas, yes that method would work but ideally I stil want to have a
button to open the website, it's just a bit more intuitive to click a
button. Also there will be buttons to open other details about each customer
so therefore I want to keep the consistency.
 
Try this:

Private Sub CmdlaunchIE_click()
Dim myIEApp As Object
Dim mystr As String
On Error Resume Next
mystr = "http://www.microsoft.com"
Set myIEApp = GetObject(, "InternetExplorer.Application")
If Err.Number <> 0 Then Set myIEApp = CreateObject
("InternetExplorer.Application")
Err.Clear ' Clear Err object in case error occurred.
myIEApp.Visible = True
myIEApp.Navigate mystr
End Sub

Just watch the line wrapping on the line that starts If
Err.Number

Dave
 
hey Dave,

I tried your procedure and I get a "Compile Error: Argument not optional"
error

The debugger highlights the "CreateObject" code on this line:
If Err.Number <> 0 Then Set myIEApp = CreateObject

Any Ideas? Am I missing a reference?

I have access2000.

thanks


Try this:

Private Sub CmdlaunchIE_click()
Dim myIEApp As Object
Dim mystr As String
On Error Resume Next
mystr = "http://www.microsoft.com"
Set myIEApp = GetObject(, "InternetExplorer.Application")
If Err.Number <> 0 Then Set myIEApp = CreateObject
("InternetExplorer.Application")
Err.Clear ' Clear Err object in case error occurred.
myIEApp.Visible = True
myIEApp.Navigate mystr
End Sub

Just watch the line wrapping on the line that starts If
Err.Number

Dave
 
Make sure that the name of your button is CmdlaunchIE.

References:
Visual Basic For Applications
Microsoft Access Object Library
OLE Automation
Microsoft ActiveX Data Objects library

Dave
-----Original Message-----
Hmm, thanks for the help but that code doesn't seem to
work, i've done as you said and watched for word wrapping
on thath particular line but when I press the buton
nothing happens. Any other ideas?
 
Kevin,

References in Access 2000
Visual Basic For Applications
Microsoft Access Object Library
OLE Automation
Microsoft ActiveX Data Objects library

Dave
 
hey Dave,

Those are basically the default references. The Access Object Library is
9.0 -- I did have the ADO 2.1 library referenced and up'd it to 2.7 -- but I
am still getting the same error -- Compile Error: Argument not optional.
This is just a dev app -- do I need to compile it to have that procedure
available? I closed out of access after changing the references -- I assume
that is all that is need there as the 2.7 library shows as checked.

thanks

Kevin,

References in Access 2000
Visual Basic For Applications
Microsoft Access Object Library
OLE Automation
Microsoft ActiveX Data Objects library

Dave
 
Hi Richard,
Niklas had the right idea. You can put a
hyperlink on a button. Open the button properties in
design view and choose hyperlink address.

The Easy Day
-----Original Message-----
Hmm, thanks for the help but that code doesn't seem to
work, i've done as you said and watched for word wrapping
on thath particular line but when I press the buton
nothing happens. Any other ideas?
 
Kevin,

Just realised that you probably have the code like this:

If Err.Number <> 0 Then Set myIEApp = CreateObject
("InternetExplorer.Application")

All the above must be on one line i.e this bit
("Intenet.Explorer.Application")

Must go after Createobject.

Dave
 
Back
Top