Test and Measurement Forum

DDE data logging and Access 2003

Post your VB and VBA discussions here

DDE data logging and Access 2003

Postby BigRedCat » Mon Dec 31, 2007 9:50 am

I have just started using an ADC-20 data logger to record clean room air pressures in our hospital radiopharmacy. The Logger works fine but I want to record the measurements in to an Access 2003 database. I have written the code to receive the data using DDE but find that all I can see is the recordings from the first channel. I am recording measurements on two differential channels - how do I see the measurements from channel 3 & 4?
BigRedCat
User
User
 
Posts: 3
Joined: Fri Dec 28, 2007 3:17 pm
Location: United Kingdom

Sorted problem

Postby BigRedCat » Mon Dec 31, 2007 1:05 pm

I have sorted the problem, did'nt realise that all values were output with carriage returns between channels, just a little programming to select the readings and it works fine.
BigRedCat
User
User
 
Posts: 3
Joined: Fri Dec 28, 2007 3:17 pm
Location: United Kingdom

Access

Postby Damian » Sun Feb 17, 2008 3:05 pm

Hi

Any chance you can assist with the code for Access - I've got excel working but would much prefer to record all sample results in a database (in order to create charts based on time periods selected by the user).
Damian
Active User
Active User
 
Posts: 5
Joined: Wed Oct 18, 2006 9:45 pm
Location: Cheshire

DDE and Access 2003

Postby BigRedCat » Mon Feb 25, 2008 3:01 pm

Here is the code I have written for a form which logs two pressure readings from a transducer. I have set the timer event to record the readings every 10seconds and then after 150 readings the average is calculated and written into the database.
The first code is the open event and sets up the CHAN parameters.
The second code is for the timer event.
I had problems accessing the second set of readings until I realised that they were all output as a single string and so had to use 'mid' and 'len' statements to separate them out.
Hope this helps you.

Laurence Scott


Code:-

Private Sub Form_Open(Cancel As Integer)
CHAN = DDEInitiate("PLW", "Current")
End Sub



Private Sub Form_Timer()

On Error GoTo errmessage

ReturnData1 = DDERequest(CHAN, "Name")
ReturnData2 = DDERequest(CHAN, "Value")
ReturnData3 = DDERequest(CHAN, "Units")
ReturnData4 = DDERequest(CHAN, "Alarm")

ReadingCount = ReadingCount + 1

If ReadingCount < 151 Then
ChangeReading = ChangeReading + Val(Mid(ReturnData2, 9, 13))
CleanReading = CleanReading + Val(Mid(ReturnData2, 1, 6))
ChangeAlarm = Val(Mid(ReturnData4, 4, 1))
CleanAlarm = Val(Mid(ReturnData4, 1, 1))
If CleanAlarm > 0 Or ChangeAlarm > 0 Then
' Reading below alarm - record reading
DoCmd.GoToRecord , , acNewRec
RecordingTime.VALUE = Now()
CleanRoomAlarm.VALUE = "O.K."
ChangeRoomAlarm.VALUE = "O.K."
If CleanAlarm > 0 Then CleanRoomAlarm.VALUE = "Alarm"
If ChangeAlarm > 0 Then ChangeRoomAlarm = "Alarm"
CleanRoom.VALUE = Mid(ReturnData1, 1, 21)
ChangeRoom.VALUE = Mid(ReturnData1, 24, Len(ReturnData1))
CleanRoomReading.VALUE = Val(Mid(ReturnData2, 1, 6))
ChangeRoomReading.VALUE = Val(Mid(ReturnData2, 9, 13))
End If
Else
DoCmd.GoToRecord , , acNewRec
RecordingTime.VALUE = Now()
CleanRoom.VALUE = Mid(ReturnData1, 1, 21)
ChangeRoom.VALUE = Mid(ReturnData1, 24, Len(ReturnData1))
CleanRoomReading.VALUE = CleanReading / ReadingCount
ChangeRoomReading.VALUE = ChangeReading / ReadingCount
CleanRoomAlarm.VALUE = "O.K."
ChangeRoomAlarm.VALUE = "O.K."
ReadingCount = 0
CleanReading = 0
ChangeReading = 0
End If

Exit Sub

errmessage:

MsgBox (Err.Description)
End Sub
BigRedCat
User
User
 
Posts: 3
Joined: Fri Dec 28, 2007 3:17 pm
Location: United Kingdom

Postby Damian » Mon Feb 25, 2008 3:15 pm

Laurence

Thank you for the code - I'll try it out later tonight

Cheers

Damian
Damian
Active User
Active User
 
Posts: 5
Joined: Wed Oct 18, 2006 9:45 pm
Location: Cheshire

Postby Damian » Thu Mar 06, 2008 6:08 pm

Hi Lawrence

Sorry to bother you again - finally had a stab at the code in Access and for some reason "The DDE conversation was interrupted" error keeps appearing. Doesn't even get past initial ReturnData1 line for the 'chan name'.

Any clues - is it something to do with the VBA refrences?
Damian
Active User
Active User
 
Posts: 5
Joined: Wed Oct 18, 2006 9:45 pm
Location: Cheshire

Access VBA

Postby Damian » Sat Mar 15, 2008 1:57 pm

Anyone?
Damian
Active User
Active User
 
Posts: 5
Joined: Wed Oct 18, 2006 9:45 pm
Location: Cheshire


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests