469,125 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

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 684

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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.