Solved

Invoke an MSAccess vba procedure from web browser buttonclick

Posted on 2004-08-12
12
3,570 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now