amorosik
Active member
- Local time
- Today, 23:10
- Joined
- Apr 18, 2020
- Messages
- 775
For the benefit of those interested in the subject I would like to share the results of my research at the present time
With the aim of sending information to an Access procedure in asynchronous mode (for example messages arriving from an Mqtt server or from Firebase) so that they can be processed by the code inside the procedure itself, they are:
- vbs script
- tcp / udp socket
- activeX
-------------------------------------------------
Vbs script
-------------------------------------------------
t is the only system that does not interfere with the main Access procedure, in the sense that from the vba code it is not necessary to do anything, except to set up a Sub of the Public type to be started in order to perform the planned activities
The content of the vbs script, to be started every time you want to communicate with the main Access procedure, is of the type
On Error Resume Next
dim mde_name mde_name = "c: \ test \ Erp2_2013.accde"
Set wmi = GetObject ("winmgmts:")
Set procs = wmi.ExecQuery ("select * from Win32_Process Where Name = 'MsAccess.exe'")
If procs.Count = 0 Then
wscript.Quit
end if
Set oApp = GetObject (mde_name) .Application
If Err.Number <> 0 Then
Set oApp = Nothing wscript.Quit
End If
oApp.Run "EVENT_LISTENER", strArgomenti
Set oApp = Nothing
Where the parameter strArgomenti is obviously one or more arguments that the Sub Event_Listener (of the main Access procedure) accepts as input
-------------------------------------------------
Socket tcp / udp
-------------------------------------------------
It is about taking advantage of the MsWinsck.ocx control produced by Microsoft which allows you to activate a tcp or udp server in a form of the main Access procedure, which must always remain active, and await the commands sent by a client 'tuned' to the same address / port of the PC where the Access procedure is running
In essence, it is:
- register the control (regsvr32.exe c: \ windows \ mswinsck.ocx)
- insert it in the Access References
- create the txcServer object
- define the Sub corresponding to the events connected to the newly created object and at least ConnectionRequest, DataArrival, Close
This system has pros and cons, the pros are the speed in managing the event (2-3 mSec from each single event) because the connection with the client is always active and does not require negotiations, the cons is that the use of the additional control is not always ' simple
Some examples available on network
-------------------------------------------------
ActiveX
-------------------------------------------------
It is essentially a system similar to the one above that uses the standard MsWinsck.ocx control, but being the control completely to be developed from scratch, it certainly allows greater control over every necessary functionality.
Technically you could also use the Visual basic 6 environment
Personally I have tried several guides to the realization of ActiveX using Visual Studio and C # as language, but despite having managed to obtain the compilation of a skeleton of the required control, I have not yet been able to complete a prototype with the minimum functionalities
Useful link
With the aim of sending information to an Access procedure in asynchronous mode (for example messages arriving from an Mqtt server or from Firebase) so that they can be processed by the code inside the procedure itself, they are:
- vbs script
- tcp / udp socket
- activeX
-------------------------------------------------
Vbs script
-------------------------------------------------
t is the only system that does not interfere with the main Access procedure, in the sense that from the vba code it is not necessary to do anything, except to set up a Sub of the Public type to be started in order to perform the planned activities
The content of the vbs script, to be started every time you want to communicate with the main Access procedure, is of the type
On Error Resume Next
dim mde_name mde_name = "c: \ test \ Erp2_2013.accde"
Set wmi = GetObject ("winmgmts:")
Set procs = wmi.ExecQuery ("select * from Win32_Process Where Name = 'MsAccess.exe'")
If procs.Count = 0 Then
wscript.Quit
end if
Set oApp = GetObject (mde_name) .Application
If Err.Number <> 0 Then
Set oApp = Nothing wscript.Quit
End If
oApp.Run "EVENT_LISTENER", strArgomenti
Set oApp = Nothing
Where the parameter strArgomenti is obviously one or more arguments that the Sub Event_Listener (of the main Access procedure) accepts as input
-------------------------------------------------
Socket tcp / udp
-------------------------------------------------
It is about taking advantage of the MsWinsck.ocx control produced by Microsoft which allows you to activate a tcp or udp server in a form of the main Access procedure, which must always remain active, and await the commands sent by a client 'tuned' to the same address / port of the PC where the Access procedure is running
In essence, it is:
- register the control (regsvr32.exe c: \ windows \ mswinsck.ocx)
- insert it in the Access References
- create the txcServer object
- define the Sub corresponding to the events connected to the newly created object and at least ConnectionRequest, DataArrival, Close
This system has pros and cons, the pros are the speed in managing the event (2-3 mSec from each single event) because the connection with the client is always active and does not require negotiations, the cons is that the use of the additional control is not always ' simple
Some examples available on network
-------------------------------------------------
ActiveX
-------------------------------------------------
It is essentially a system similar to the one above that uses the standard MsWinsck.ocx control, but being the control completely to be developed from scratch, it certainly allows greater control over every necessary functionality.
Technically you could also use the Visual basic 6 environment
Personally I have tried several guides to the realization of ActiveX using Visual Studio and C # as language, but despite having managed to obtain the compilation of a skeleton of the required control, I have not yet been able to complete a prototype with the minimum functionalities
Useful link
Code:
https://codedocu.com/Details_mobile?d=2075&z=1&t=Code%3A+Create+your+own+ActiveX+Component+in+Visual+Studio+2017+and+Office+2016+365
https://www.codeguru.com/csharp/.net/net_general/comcom/article.php/c16257/Create-an-ActiveX-using-a-Csharp-Usercontrol.htm
https://stackoverflow.com/questions/49469926/using-withevents-in-vb6-with-net-vb-dll
Last edited: