Link to home
Start Free TrialLog in
Avatar of Alan Warren
Alan WarrenFlag for Philippines

asked on

Invoke an MSAccess vba procedure from web browser buttonclick

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
Avatar of rockiroads
rockiroads
Flag of United States of America image

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
Avatar of Alan Warren

ASKER


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


SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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


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

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


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
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


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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