Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3600
  • Last Modified:

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
0
Alan Warren
Asked:
Alan Warren
  • 5
  • 4
  • 2
  • +1
3 Solutions
 
rockiroadsCommented:
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
 
Alan WarrenAuthor Commented:

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
 
rockiroadsCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Alan WarrenAuthor Commented:
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
 
rockiroadsCommented:
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
 
Alan WarrenAuthor Commented:
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
 
rockiroadsCommented:
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
 
Alan WarrenAuthor Commented:
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
 
SidFishesCommented:
alan...i think if you have a properly patched system you won't be able to do this...

http://accessadvisor.net/doc/09337

0
 
flavoCommented:
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
 
flavoCommented:
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
 
Alan WarrenAuthor Commented:
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now