I wrote a module in an Access file, and is it possible via VB call Access to
execute that module and how to do that?
Thanks a lot!!
Hanry
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")
objAccess.Visible = False
objAccess.OpenCurrentDatabase "c:\DB.mdb"
objAccess.Run "TestFunc"
Best Regards,
Alick Ye
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Hanry" <han...@freeduty.com.hk>
Subject: VB how to call Access Module!!
Date: Thu, 1 Aug 2002 14:14:40 +0800
Lines: 10
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <Oom5rISOCHA.2480@tkmsftngp08>
Newsgroups: microsoft.public.vb.general.discussion
NNTP-Posting-Host: 202.64.210.118
Path: cpmsftngxa07!tkmsftngxs01!tkmsftngp01!tkmsftngp08
Xref: cpmsftngxa07 microsoft.public.vb.general.discussion:368506
X-Tomcat-NG: microsoft.public.vb.general.discussion
But after try that, I get the error about cannot find the procedure, but I
make sure that I have the same function name in the module.
Thanks again!
Hanry
"Alick [MS]" <al...@online.microsoft.com> wrote in message
news:6GIfw#SOCHA.2348@cpmsftngxa07...
In Access:
a. In Access, create a new document.
b. Press ALT+F11 to open the Visual Basic Editor.
c. On the Insert menu, click Module.
d. Paste the following macro code into the new module:
'Display a message box that displays the application name.
Public Sub DoKbTest()
MsgBox "Hello from " & Application.Name
End Sub
'Display a message box with the string passed from the
'Automation client.
Public Sub DoKbTestWithParameter( sMsg As String )
MsgBox sMsg
End Sub
e. Close the Visual Basic Editor, save the Access file as "c:\db1.mdb",
quit Access.
In Visual Basic:
1. Create a new Standard execute application, add a button on the
form.
2. Click menu "Project/References", find "Microsoft Access 10.0
Object library" and have it checked. (version number 10.0 may change)
3. Add following code in the program and run it:
Private Sub Command1_Click()
Dim oAccess As Access.Application
Set oAccess = CreateObject("Access.Application")
oAccess.Visible = False
Call oAccess.OpenCurrentDatabase("c:\db1.mdb", False)
oAccess.Run ("DoKbTest")
Call oAccess.Run("DoKbTestWithParameter", "Hello from VB Client")
oAccess.Quit
Set oAccess = Nothing
End Sub
Best Regards,
Alick Ye
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Hanry" <han...@freeduty.com.hk>
| References: <Oom5rISOCHA.2480@tkmsftngp08> <6GIfw#SOCHA.2348@cpmsftngxa07>
| Subject: Re: VB how to call Access Module!!
| Date: Thu, 1 Aug 2002 16:06:18 +0800
| Lines: 66
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <ODh6FHTOCHA.1756@tkmsftngp08>
| Newsgroups: microsoft.public.vb.general.discussion
| NNTP-Posting-Host: 202.64.210.118
| Path: cpmsftngxa07!tkmsftngp01!tkmsftngp08
| Xref: cpmsftngxa07 microsoft.public.vb.general.discussion:368564
| X-Tomcat-NG: microsoft.public.vb.general.discussion