Call access modulo /macro from vb6
-
- PlatinumLounger
- Posts: 4605
- Joined: 26 Apr 2010, 17:36
Call access modulo /macro from vb6
I just have a module in access data base possible to call it via vb 6.0?
Note:
i just have a ADO jet connection actine in vb 6.0 project tath point to a access database where is the module.
Note:
i just have a ADO jet connection actine in vb 6.0 project tath point to a access database where is the module.
-
- Administrator
- Posts: 80207
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call access modulo /macro from vb6
You'd have to run Access from your VB6 application. It would be easier to copy the code into your application.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4605
- Joined: 26 Apr 2010, 17:36
Re: Call access modulo /macro from vb6
No.
I Need to run via vb6.
Tks
An example palese.
I Need to run via vb6.
Tks
An example palese.
-
- Administrator
- Posts: 80207
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call access modulo /macro from vb6
Code: Select all
Dim objAccess As Object
Set objAccess = CreateObject(Class:="Access.Application")
objAccess.OpenCurrentDatabase "C:\MyFolder\MyDatabase.mdb"
objAccess.Run "MyProcedure"
objAccess.Quit
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4605
- Joined: 26 Apr 2010, 17:36
Re: Call access modulo /macro from vb6
Tks Bro.HansV wrote: ↑05 Nov 2024, 23:16Code: Select all
Dim objAccess As Object Set objAccess = CreateObject(Class:="Access.Application") objAccess.OpenCurrentDatabase "C:\MyFolder\MyDatabase.mdb" objAccess.Run "MyProcedure" objAccess.Quit
Dubt...
In my vb6 project have a public variabile i can pass It in the access modulo?
-
- Administrator
- Posts: 80207
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call access modulo /macro from vb6
Does the procedure (Sub) in the Access database have an argument? For example
or
If so, you can use
where MyVar is the name of your public variable.
Otherwise: no.
Code: Select all
Sub MyProcedure(Regione As String)
Code: Select all
Sub MyProcedure(Anno As Long)
Code: Select all
objAccess.Run "MyProcedure", MyVar
Otherwise: no.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 753
- Joined: 27 Jun 2021, 10:46
Re: Call access modulo /macro from vb6
>I Need to run via vb6
Is this because you (or your users) won't have Access? In which case Hans' solution won't work because it essentially is running Access (because, as he says, you need to do that to meet your requirement)
Having an 'ADO jet connection' only gives you access to the Jet SQL database, not to the entire Access database management system
Is this because you (or your users) won't have Access? In which case Hans' solution won't work because it essentially is running Access (because, as he says, you need to do that to meet your requirement)
Having an 'ADO jet connection' only gives you access to the Jet SQL database, not to the entire Access database management system
-
- PlatinumLounger
- Posts: 4605
- Joined: 26 Apr 2010, 17:36
Re: Call access modulo /macro from vb6
I have the module in image, and the procedure is named sub WebAutomationSelenium ()sal21 wrote: ↑06 Nov 2024, 08:09Tks Bro.HansV wrote: ↑05 Nov 2024, 23:16Code: Select all
Dim objAccess As Object Set objAccess = CreateObject(Class:="Access.Application") objAccess.OpenCurrentDatabase "C:\MyFolder\MyDatabase.mdb" objAccess.Run "MyProcedure" objAccess.Quit
Dubt...
In my vb6 project have a public variabile i can pass It in the access modulo?
is correct, in my tyest code:
Option Explicit
Private Sub Form_Load()
Dim objAccess As Object
Set objAccess = CreateObject(Class:="Access.Application")
objAccess.OpenCurrentDatabase "C:\Lavori_Vb6\MAPPA_ITALIA\DATABASE\COMUNI.mdb"
objAccess.Run "CHROME_TEST"
objAccess.Quit
End Sub
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 80207
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call access modulo /macro from vb6
You have to use the name of the procedure, not the name of the module.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4605
- Joined: 26 Apr 2010, 17:36
Re: Call access modulo /macro from vb6
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 80207
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call access modulo /macro from vb6
Are you sure that you spelled the name correctly? And that the procedure is not Private?
Similar code works correctly for me!
Similar code works correctly for me!
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4605
- Joined: 26 Apr 2010, 17:36
Re: Call access modulo /macro from vb6
objAccess.Run "WebAutomationSeleniumo"
Code: Select all
Option Compare Database
Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub WebAutomationSelenium()
Dim bot As Object, VALORE As String, ISTAT As String
Dim Table As Object, Rows As Object, Row As Object, Cells As Object, Cell As Object
Dim I As Integer, J As Integer
Set bot = CreateObject("Selenium.WebDriver")
bot.Start "Chrome"
bot.Get "https://demo.istat.it/app/?i=D7B&l=it&a=2024"
bot.Window.Maximize
Sleep 2000
bot.FindElementById("tab-1").Click
Sleep 2000
bot.FindElementById("provincerb-1").Click
Sleep 2000
bot.ExecuteScript "document.getElementById('province-1').removeAttribute('disabled');"
Sleep 2000
Dim provinceDropdown As Object
Set provinceDropdown = bot.FindElementById("province-1")
For I = 1 To provinceDropdown.FindElementsByTag("option").Count - 1
If provinceDropdown.FindElementsByTag("option")(I).Text = "Como" Then
provinceDropdown.FindElementsByTag("option")(I).Click
Exit For
End If
Next
Sleep 1000
Dim monthDropdown As Object
Set monthDropdown = bot.FindElementById("mese")
For I = 1 To monthDropdown.FindElementsByTag("option").Count '- 1
'Debug.Print monthDropdown.FindElementsByTag("option")(I).Text
If monthDropdown.FindElementsByTag("option")(I).Text = "Luglio" Then
'Debug.Print monthDropdown.FindElementsByTag("option")(I).Text
monthDropdown.FindElementsByTag("option")(I).Click
Exit For
End If
Next
Sleep 1000
bot.FindElementById("btnricerca-1").Click
Sleep 1000
Set Table = bot.FindElementById("tavola-form-1")
Set Rows = Table.FindElementsByTag("tr")
For I = 1 To Rows.Count - 1
Set Row = Rows.Item(I)
Set Cells = Row.FindElementsByTag("td")
For J = 1 To Cells.Count - 1
Set Cell = Cells.Item(J)
VALORE = "Row " & I & ", Column " & J & ": " & Cell.Text
ISTAT = Cell.Text
Debug.Print VALORE
Next J
Next I
bot.Quit
Set bot = Nothing
End Sub
-
- 5StarLounger
- Posts: 753
- Joined: 27 Jun 2021, 10:46
Re: Call access modulo /macro from vb6
As Hans says "And that the procedure is not Private?"
Private Sub WebAutomationSelenium()
Private Sub WebAutomationSelenium()
-
- Administrator
- Posts: 80207
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Call access modulo /macro from vb6
Change Private Sub to Public Sub.
Alternatively, try
objAccess.Run "CHROME_TEST.WebAutomationSelenium"
Alternatively, try
objAccess.Run "CHROME_TEST.WebAutomationSelenium"
Best wishes,
Hans
Hans