Sign in to follow this  
Followers 0
vbdummy

serial comm using ms-access vba

4 posts in this topic

#1 ·  Posted (edited)

This is part of the code i wrote in the vba in ms access. try to get data from a scale via RS232. this code works, but have to click the command button twice to get the "current" value. there are three buttons on this form. the first one is used to enable the por, the second one is to disable it, while the third one is to send the command and get the data back from serial port.

the command works, and i tried it in the HyperTerminal in windows. however, in my program, the first click on the command button, it only returns the "previous" value. the second touch gives me the current value. i'm new to vba, but have to figure this out.

please help me find the problem. i will really appreaciate.

Private Sub Command75_Click()
'Open Serial Port and configure the settings

If NETComm6.PortOpen Then
    MsgBox "Serial Port is already Open", vbOKOnly, "Port Status"
Else
    NETComm6.CommPort = 2 'set the port number
    NETComm6.PortOpen = True 'open port
    NETComm6.RThreshold = 1
    NETComm6.InBufferCount = 0 'Flush the Buffer
    NETComm6.InputLen = 0 ' Tell the control to read entire buffer when Input is used.
End If
End Sub
 
Private Sub Command76_Click()
'Close Serial Port

If NETComm6.PortOpen Then
    NETComm6.CommPort = 2
    NETComm6.InBufferCount = 0
    NETComm6.PortOpen = False
Else
    MsgBox "Serial Port is already closed", vbOKOnly, "Port Status"
End If
End Sub

Private Sub Command77_Click()
'send the Print command and read the weight value.
NETComm6.Output = "p" & Chr(13) 'send PRINT command to the scale.
Dim Buffer As String 'define Buffer
    Buffer$ = Buffer$ & NETComm6.InputData 'wait for the data come into the serail port
    WtInfo = Buffer
End Sub

*WtInfo is a textbox in access form

Edited by vbdummy

Share this post


Link to post
Share on other sites



This is a forum for AutoIt not vba.

But if you want to get the job done in AutoIt then ask away. ;)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

This is a forum for AutoIt not vba.

But if you want to get the job done in AutoIt then ask away. ;)

sorry, post in the wrong place. where can i ask in this forum, or at all?

Share this post


Link to post
Share on other sites

sorry, post in the wrong place. where can i ask in this forum, or at all?

Not at all I think. You need to find a vba site/forum.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0