Solved

Invoke an MSAccess vba procedure from web browser buttonclick

Posted on 2004-08-12
12
3,572 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
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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

929 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

6 Experts available now in Live!

Get 1:1 Help Now