471,853 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

vbscript memvar manipulation.

3
Hello,
I am trying to interface serial data logging to msaccess database.
Following macro-module-code works fine.

Function GetCPSData()

Dim ChannelNumber As Variant
Dim MyData As String
ChannelNumber = DDEInitiate("CPSPLUS", "DRIVER")
MyData = DDERequest(ChannelNumber, "COM1_VALUE")
DDETerminate ChannelNumber
If Len(MyData) = 0 Then Exit Function


Dim MyDB, MyTable
'Dim MyDB As Database, MyTable As Recordset
' NOTE!!! For Access Versions earlier than 2000


Set MyDB = CurrentDb()
Set MyTable = MyDB.OpenRecordset("TABLE1")

MyTable.AddNew
MyTable![serialdata] = MyData
MyTable.Update
MyTable.Close

End Function fine.

But I need to use part of mydata string

If I make following change I get fail sql statement error

Function GetCPSData()

Dim ChannelNumber As Variant
Dim MyData As String
Dim X As String
Dim Y As String
ChannelNumber = DDEInitiate("CPSPLUS", "DRIVER")
MyData = DDERequest(ChannelNumber, "COM1_VALUE")
DDETerminate ChannelNumber
If Len(MyData) = 0 Then Exit Function

X = Mid$("MyData", 16, 21)
Y = Mid$("MyData", 22, 25)

Dim MyDB, MyTable
'Dim MyDB As Database, MyTable As Recordset
' NOTE!!! For Access Versions earlier than 2000


Set MyDB = CurrentDb()
Set MyTable = MyDB.OpenRecordset("TABLE1")

MyTable.AddNew
MyTable![serialdata] = MyData
MyTable![x] = x
MyTable![y] = y
MyTable.Update
MyTable.Close

End Function


What is needed?
Jun 20 '07 #1
0 737

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

29 posts views Thread by Christopher Brandsdal | last post: by
20 posts views Thread by Harag | last post: by
16 posts views Thread by Mike Schinkel | last post: by
6 posts views Thread by rishabhshrivastava | last post: by
NeoPa
reply views Thread by NeoPa | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.