Datas collection from "virtual-com" ports to access (1 Viewer)

jeppe

Registered User.
Local time
Today, 14:22
Joined
Jun 5, 2006
Messages
16
Hi, I have a problem whit datas collection.

I have next devices, The NPort W2250/2150 Wireless Serial Device Server (http://www.moxa.com/product/NPort_W22502150.htm) and bar code rider which is connected to the Nport.

I can communicate to Nport using virtual COM-port. Bar code rider sends a number codes. I would want to move the datas from virtual COM-port to Access.

What is the best way listen a COM-port and get the datas to Access? operationg system is Win98 and Access is 97.
All information are welcome! :)

Thanks
 
Last edited:

allan57

Allan
Local time
Today, 13:22
Joined
Nov 29, 2004
Messages
336
I Send and Receive Data Via the Serial Port Using MSComm Control, this can be used in both Access and VB.

Search the web using MSComm as your criteria as there are plenty of examples on how to implement this into your programs.
 

jeppe

Registered User.
Local time
Today, 14:22
Joined
Jun 5, 2006
Messages
16
Okay, thank you. I haven't VB so may I need it program? Does work MSComm Control in Access without VB...
 

KeithG

AWF VIP
Local time
Today, 05:22
Joined
Mar 23, 2006
Messages
2,592
I am not positive but I believe you must have VB6 or VB.Net installed on your pc to use the mscomm control becuase it is a licensenced control. I am currently trying to VB6 installed on my PC to use mscomm. What kind of scanner do you use?
 

jeppe

Registered User.
Local time
Today, 14:22
Joined
Jun 5, 2006
Messages
16
Does work MSComm in a VBA codes on Access 97? like..

' Open the serial port
MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True

I am rookie yet...thanks for link.
 

allan57

Allan
Local time
Today, 13:22
Joined
Nov 29, 2004
Messages
336
The following is an extract from MS:

MSComm Control Example
The following simple example shows basic serial communications using a modem:

Private Sub Form_Load ()
' Buffer to hold input string
Dim Instring As String
' Use COM1.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
' Send the attention command to the modem.
MSComm1.Output = "ATV1Q0" & Chr$(13) ' Ensure that
' the modem responds with "OK".
' Wait for data to come back to the serial port.
Do
DoEvents
Buffer$ = Buffer$ & MSComm1.Input
Loop Until InStr(Buffer$, "OK" & vbCRLF)
' Read the "OK" response data in the serial port.
' Close the serial port.
MSComm1.PortOpen = False
End Sub

Note The MSComm control can use polling or an event-driven method to retrieve data from the port. This simple example uses the polling method. For an example of the event-driven method, see help for the OnComm event.

Also check out the following link:

http://support.microsoft.com/default.aspx?scid=kb;en-us;194922
 
Last edited:

jeppe

Registered User.
Local time
Today, 14:22
Joined
Jun 5, 2006
Messages
16
okay, I learn how I can open and close the port. Next problem is...

I have in the database three tables com1, com2 and com3. (The names are example). In com1 table are two fields, "serial code" and "savetime". Is in Access 97 some automatic object each saving automatic a datas to fields?

The bar code reader sends the serial code to COMport 1. The table and fields are ready...so What is the best way move and add the datas to database?

I have heard that Winsock is also good? Or is that wrong guess..
 

allan57

Allan
Local time
Today, 13:22
Joined
Nov 29, 2004
Messages
336
Data that’s captured by MSComm1.Input can be stored to any table using Recordsets or SQL Statement.
 

ian_w

Registered User.
Local time
Today, 13:22
Joined
Jun 13, 2006
Messages
64
is it possible to send data to COM1 i.e a printer using MSCOMM?
 

allan57

Allan
Local time
Today, 13:22
Joined
Nov 29, 2004
Messages
336
Do you mean using your Access database as a printer emulator, if so yes.
 

jeppe

Registered User.
Local time
Today, 14:22
Joined
Jun 5, 2006
Messages
16
I have got a devices and tested these. They works well...I can monitor the virtual com port in PComm Lite. http://web4.moxa.com/support/download.asp#2_PComm2K_V1.3.zip

So I am do the database in Access97. There will be a table including three fields.
ID bar code date
1 12345
2 12345
3 12344
. ......
.

I have read information from net etc..I try do the right code..I have plan do a macro-button in database which opens and update the database. Is real time updates possible? Below is my codes...this not be ready! But I am grateful of comments and infos. Thanks

Private Sub Form_Load()

MSComm1.CommPort = 1
MSComm1.Handshaking = 0
MSComm1.Rthreshold = 0
MSComm1.Settings = 9600,N,8,1
MSComm1.InputLen = 0
MSComm1.PortOpen = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False ' Close the com port
End Sub

' Command Button to open or close the port
Private Sub Command1_Click()
If MSComm1.PortOpen = False Then ' If com port is not open
MSComm1.PortOpen = True ' Open it
Command1.Caption = "Close Port" ' Modify the caption of the button
Else
MSComm1.PortOpen = False ' If the port is open the close it
Command1.Caption = "Open Port" ' Again modify the caption
End If
End Sub

Private Sub MSComm1_OnComm()

If MSComm1.InBufferCount > 0 Then ' If theres data in com buffer

??? What the next...?

Dim update As Database
Dim rs As Recordset
Dim rsbarcode As Recordset

Private Sub

or something like this..

Dim update As ADODB.Connection

Set update = New ADODB.Connection
update.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb;"
update.Open
 

Users who are viewing this thread

Top Bottom