Yes, with QuickOPC, you can use VBA inside Microsoft Access to access OPC Classic, OPC XML-DA and OPC UA (Unified Architecture) data.
(It should be said that what you have described can also be done in different ways. In principle there is no need for the code to reside inside the Access database - both the OPC access and the database access can be arranged from some "outside" program written in any suitable tools, such as in .NET. But you may have your own good reasons for doing it the way you suggested, such as if you already have an existing application code using this VBA approach).
In a nutshell, here is what you need to do for getting the first data through:
- In your VBA, reference the necessary QuickOPC type library/libraries: See opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...0the%20Components%20(COM).html .
- On the appropriate place in your code, add statements to create our EasyDAClient or EasyUAClient object, and call its method such as ReadItemValue or ReadValue (see further below).
- Use the obtained value and process it as you need - e.g. insert it into some table.
Attached is a database (zipped) that I have made from a blank project. I added a form and set it as startup form, and then I have added code to the Load event of the form to read OPC data and display them in a text box.
(QuickOPC 2021.2 needs to be installed, with "COM development" choice selected in the Setup wizard, for this to work).
The code in the form is as follows:
Private Sub Form_Load()
' Create EasyOPC-UA component
Dim Client As New EasyUAClient
' Read node value and display it
Text0 = Client.ReadValue("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/;i=10853")
End Sub
I hope this helps. Feel free to ask additional questions - but I suggest you look around the documentation (
www.opclabs.com/documentation ) and the examples available too.
Best regards