 |
|
|
Topic: MSAccess 2003 Form and SComm32
|
By: David | Posted on: Jun 2 2015 at 07:10:06 PM | I am creating an application to log GPS and depth sounder serial data on my boat. I can get this working fine using Excel 2003, by placing 2 SComm32 controls on a worksheet and opening their respective ports using VBA. The On Comm event then triggers collection of data to text boxes, where it is parsed to extract the values I want and then written to the appropriate cells on another worksheet.
The processing overhead in Excel is such that there is some dropout of the GPS data (which updates once a second). I would prefer to capture the raw data to an Access database, but SComm32 seems to behave rather differently in VBA for Access. If I place an SComm32 object on a form, then the only actions I can apply in VBA to the object are not related to serial data (Height, Visible, Control Tip Text, etc)
If I declare an SComm variable in a procedure, either directly or via CreateObject, I can access the serial data actions, but the SComm disappears when the procedure has run. If I declare Public COM1 as SComm, I can then open the SComm's port from a procedure, but I can't use the On Comm event.
What I am looking for is a simple way of placing an SComm32 object on a form, opening its port via a button click and then using the On Comm or similar event to trigger data gathering, in the manner which is easily done in Excel. Any and all advice welcomed!!
| |
By: Support | Posted on: Jun 2 2015 at 09:23:04 PM | A known problem with Access/VBA is that IntelliSense doesn't work if you put the control on a form. But you can still use the properties and Methods.
For example if you put the control on a form VBA might give it the name "SComm0" or "SComm1". In code when you key in SComm0 followed by a dot the list of properties appears. But the list doesn't include any of the Comm properties. But ignore that and key in the name of the property or method and VBA accepts it.
Same with the OnComm event. VBA won't create the event for you automatically but if you key it in to your code manually then it'll work.
Private Sub SComm0_OnComm()
' Do stuff here
End Sub
Intellisense. That list of properties that pops up when you key in the name of control followed by a dot). It doesn't always work in VBA with non-microsoft controls. But if you google it you'll find lots of people complaining about it and also ways to fix it. But if you put the control on a form the properties do show up in the properties explorer so you can set up all the static properties and, at run time, you'll mostly be just using a few such as .open .close .input etc etc so you won't need intellisense anyway. | |
|