Senin, 18 Desember 2023

Re: [MSAccessProfessionals] Experiment with Timer & VBS

hi Ozair,

if you have something you want to schedule that runs from another database, one way to do it may be to link the the same tables that your application uses -- and import any queries or other code you might need.

kind regards,
crystal

On 12/18/2023 2:28 PM, Paul Baldy wrote:
Completely untested, but you can try GetObject instead of CreateObject, or perhaps the method Daniel shows at the top here:


Paul

------ Original Message ------
From: "ozair" <ozairkhalid@hotmail.com>
Sent: 12/18/2023 9:25:07 AM
Subject: [MSAccessProfessionals] Experiment with Timer & VBS

Hi,
 
This is an experimental task.
I wanted to call MS Access file's function from, from a VBS file.
It works good but when I again run the VBS, it opens ANOTHER instance of MS Access. (this is undesirable).

It should call the function without opening another MS Access file.
All subsequent calls to the function must be answered from the file already opened.
 
Idea's background;
The original idea is to avoid using TIMER inside MS Access file. Instead create a VBS that calls MS Access file's function.
That VBS is then added to Windows Task Scheduler. I hope this would help MS Access file remain stable.
 
TIA
~ozair 
 
 
'Code in the VBS file 
Set accessApp = CreateObject("Access.Application")
accessApp.OpenCurrentDataBase "C:\Users\ozair\Desktop\DB1.accdb"
accessApp.UserControl = true
accessApp.Run "HelloMsg"
 
 
'Function in MS Access file [Module]
Public Function HelloMsg()
    MsgBox "Hello World!", vbExclamation
End Function
 

Tidak ada komentar:

Posting Komentar