Like following are the fields in my access table
SrNo. 8spaces
Date – 15 spaces
Time of Test- 10 spaces
Set Pressure-10 spaces
Achieved Pressure-9 spaces
Leak value-11 spaces
Result-10 spaces
The equipment which i connect to serial port it gives me data in above size and i want to store that data in the access table. and again to display on Vb front end.
format
I have already used Mid function but it is not working fine. here is the my code
it means now i get combined data of 2/ 3 fields in a single field of access table
but I want that data in different fields .
i used MSComm control in project
and i set following properties Inputlen=73 RThreshold = 73
if i set these properties to 1 then please suggest me the code
CODE
Private Sub Form_Load()
stranswer = InputBox("Enter the Database Name to store the records", "Database Name")
Set filesystemobject = CreateObject("scripting.filesystemobject")
'On Error GoTo copy
'MkDir "D:\data_base_copy"
'copy:
filesystemobject.copyfile "D:\data_base_copy\Processflow.mdb", "D:\data_base_copy\" + stranswer + ".mdb"
Set con = New ADODB.Connection
con.ConnectionString = "Provider = Microsoft.jet.oledb.4.0;Data Source = D:\data_base_copy\" + stranswer + ".mdb"
con.Open
Set rs = New ADODB.Recordset
rs.Open "select * from graphdb", con, adOpenDynamic, adLockOptimistic
With MSComm1
.CommPort = 1
.Handshaking = 0 - comNone
.RThreshold = 73
.RTSEnable = True
.PortOpen = True
.Settings = "19200,n,8,1"
.SThreshold = 1
.InputMode = 0 - comInputModeText
.InputLen = 73
End With
flag = -1
cnt = 0
z = 0
'Open "c:\ram.txt" For Output As #1
Timer1.Enabled = False
End Sub
Private Sub MSComm1_OnComm()
error:
Select Case MSComm1.CommEvent
Case comEventBreak
Case comEventCDTO
Case comEventCTSTO
Case comEventDSRTO
Case comEventFrame
Case comEventOverrun
Case comEventRxOver
Case comEventRxParity
Case comEventTxFull
Case comEventDCB
Case comEvCD
Case comEvCTS
Case comEvDSR
Case comEvRing
Case comEvReceive
Case comEvSend
Case comEvEOF
End Select
On Error GoTo error
rsin = MSComm1.Input
'If rsin = 74 Then
rs.AddNew
'If flag = -1 Then
' res1 = StrComp(rs, "A")
' If res1 = 0 Then
' flag = 0
' Exit Sub
' End If
'Else
r1 = Mid(rsin, 1, 8)
r2 = Mid(rsin, 9, 23)
r3 = Mid(rsin, 24, 33)
r4 = Mid(rsin, 34, 43)
r5 = Mid(rsin, 44, 52)
r6 = Mid(rsin, 53, 63)
r7 = Mid(rsin, 64, 73)
rs.Fields(0) = z
rs.Fields(1) = r1
rs.Fields(2) = r2
rs.Fields(3) = r3
rs.Fields(4) = r4
rs.Fields(5) = r5
rs.Fields(6) = r6
rs.Fields(7) = r7
z = z + 1
rs.Update
'rs.AddNew
'rs.Requery
'rs.Close
End Sub