Applies To:
  • CitectSCADA

Summary:
How do I communicate with the serial port using MS Access? 

Solution:
Using a Visual Basic object is much easier than writing pages of code. There is an existing control object called Mscomm32.ocx. Be careful to use the correct version of Visual Basic for the version of Access you are using. eg for Access 95 use Visual Basic 4. for Access 97 use Visual Basic 5, etc. To use these VB objects you must have a license for VB.

The Microsoft Register Server (regsvr32.exe), Mscomm32.ocx and Mscomm32.oca should be in you windows\system folder. Open a DOS prompt and change to the windows/system folder. The command to use is :

regsvr32 mscomm32.ocx

This will register the OCX and allow windows software to use it. You will also need a license key, which comes with your edition of VB. This is contained in a file called vbctrls.reg in VB4, and all that is required is to double-click on this file in Explorer. This adds the licence key to your registry.

The alternative to this method is to simply install VB. If you need to uninstall it, ensure you do not remove that shared component.

Now you will be able to place the Communications Control object on a form in Access, and write VBA code to access it. This makes the writing of simple serial protocols to equipment much easier, because you do not have to worry about handling the hardware at all - the OCX takes care of it all. The help information on using Microsoft Communications Control can be found in the VB documentation.

 

Keywords:
 

Attachments