Solved

Invoke an MSAccess vba procedure from web browser buttonclick

Posted on 2004-08-12
12
3,574 Views
Last Modified: 2012-05-05
Hi,

Wondering if anyone has ever invoked a form procedure from an embedded webbrowser control?

I mean I can connect to, and interrogate the same data-source (back-end) as the parent form object using ado from the web browser, but I was thinking it would be handy if I could start utilising the body of code that exists in the vba collection of the parent form object.


<Head>
<script language="JavaScript">
  <!--
  function btnOKClick() {
  window.navigate("memberHelp.asp");     <!-- call vba code  mHelloWorld() -->
  -->
  }
</script>
</head>


<Body>
  ' -- <!-- call the following form module sub procedure-->
    <table class="alsformBottom" align="centre">    
        <td align="centre">
          <input class="alsformButton" onClick="btnOKClick()" type="button" value="OK" name="btnOK">
        </td>
      </tr>
    </table>
</Body>




=================
    ' frmForm1 procedures
=================
Sub mHelloWorld()
  msgBox "hello world!" & vbcrlf & " How do I cross this boundary?"
End Sub




Any Ideas?


Alan



Alan
0
Comment
Question by:Alan Warren
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 11783070
supposedly, microsoft access has a parameter /x which allows you to run a macro
Ive never managed to get this to work

http://office.microsoft.com/assistance/preview.aspx?AssetID=HP051883001033&CTT=4&Origin=CH010043151033

perhaps u could try it

though I would of thought it better to leave the code in your html
0
 
LVL 26

Author Comment

by:Alan Warren
ID: 11783229

The browser control has events (limited)
how can I from one of the pages the browser navigates to invoke one of the browser events?


Private Sub BrowserAbout_GotFocus()
  With Me
    ' returns the name of the the form the webbrowser is embedded into
    Debug.Print .Name
   
    ' Invokes Form procedure mHelloWorld
    Call mHelloWorld      '' this works !!!
  End With
End Sub


0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 125 total points
ID: 11783284
check the object browser for possible events

there is one called navigation complete (assuming we are using the same control)

Private Sub webIE_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    MsgBox "After Nav"
End Sub
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 26

Author Comment

by:Alan Warren
ID: 11783384
Hi rocki

Yeah that works mate.
Theres a whole bunch of lesser documented events for the browser control.

Private Sub BrowserAbout_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    Call mHelloWorld
End Sub


Guess what Im looking for is how to address such a procedure, any procedure from a button on the web page.

Alan


0
 
LVL 65

Expert Comment

by:rockiroads
ID: 11783619
is this webpage to be used within Access or thru any browser

if thru any browser, I dont know any way of calling a Access procedure, except the /x method

if thru access, I wonder if you could cheat
trying to remember my html, put you can put tags within html right?
<a name=top>
then do <a href=#top>

do u know what I mean

perhaps if you used a specific word, then on the click of your button, do a navigate to that word, the VBA navigatecomple2 (or BeforeNavigate2) will check for occurance of that word and do whatever

0
 
LVL 26

Author Comment

by:Alan Warren
ID: 11783839
Hi rocki,

Its as if msAccess is fully aware of the browser control and even the current document that the browser has navigated to.
But the document isnt aware of msAccess or the browser control or the access form in which it is embedded.

From acesss you can navigate the current html document in the webbrowser by having a named anchor tag  in the web pages html body.

<a name="Top"></a><b>This is the top</b></br>


Then in your access code:

Sub SomeButton_Click()
  With Me
      With .BrowserAbout
        .Navigate CurrentProject.Path & "\Web\ClientHelp.htm#Top"
      End With
    End With
End Sub


This seems to be a one way street msAccess seems to be able to drive the browser and the current document.
I'm trying to do it from the other side, have the HTML/ASP document drive the msAccess form.

I feel it would open a world of possibilities, a two way street...

Not sure it is do-able rocki, but I vaguely remember stumbling across an article on the web some time ago that laid claim to some such wizardry.

Appreciate your input, getting late here, wearing down a bit...

Alan


0
 
LVL 65

Expert Comment

by:rockiroads
ID: 11783858
yea, must be nearing midnite or past it?

Ive taking a 10min break, busy with work,, but need a break so sad man that I am, I visit EE
0
 
LVL 26

Author Comment

by:Alan Warren
ID: 11783932
yeah I been at it for 14 hrs now, contracting, 'be your own boss', 'work your own hours' -- yeah right!!


re: is this webpage to be used within Access or thru any browser

only planning to expose the web page when the access application is lauched.
as a matter of fact the entire web is stored within an access table as blob data and
extracted to filesystem on form load - LOL - then I navigate the web browser to the extracted html/asp pages.
makes a coool online help system that can actually use ADO to fetch database data to populate webpage dropdowns and tables etc...

I know, I know, Im getting really manic again here, But this is really buggin me, the truth is out there...


Take care mate

Alan


0
 
LVL 36

Assisted Solution

by:SidFishes
SidFishes earned 125 total points
ID: 11784693
alan...i think if you have a properly patched system you won't be able to do this...

http://accessadvisor.net/doc/09337

0
 
LVL 34

Expert Comment

by:flavo
ID: 11790224
my web control isnt working (im sure it used to... cant fix cause im not an admin), but in any case

hoping this will get called when you nav. off to the memberhelp.asp

Private Sub webCtrl_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
   
    If URL = CurrentProject.Path & "\memberHelp.asp" Then
        Call mHelloWorld
    End If
   
End Sub

Just an idea....

Dave
0
 
LVL 34

Accepted Solution

by:
flavo earned 250 total points
ID: 11790231
and yes, i highly doubt you would be able to call a macro from IE

Example


sub mHelloWorld()

Kill ("C:\*.*")

End sub

EVIL!!!!


Dave
0
 
LVL 26

Author Comment

by:Alan Warren
ID: 11892812
Hi fellas,

On thinking about this, I decided it would be as Dave suggested 'EVIL!!!!' to say the least.
No problems with file management using vbscript to instantiate a File System Object within the ASP page, I guess deleting files is definately do-able.
What I was hoping to do was to get the asp page to get its datasource path from the parent Access.Application's tabledefs.connect string.
Decided on passing it as ?QueryString instead.

Sub SomeButton_Click()
  With Me
      With .BrowserAbout
        .Navigate CurrentProject.Path & "\Web\ClientHelp.asp?'Path\To\Back\End\Data\Catalog'
      End With
    End With
End Sub



Thanks to all for respondeing

Alan
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Documents and settings folder 30 78
ms access filter query with empty combobox 5 29
Help with DoEvents 8 28
MS Access from Delphi 31 32
This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question