DDE data logging and Access 2003

Post your VB and VBA discussions here
Post Reply
BigRedCat
User
User
Posts: 3
Joined: Fri Dec 28, 2007 3:17 pm
Location: United Kingdom

DDE data logging and Access 2003

Post by BigRedCat »

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

Post by BigRedCat »

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.

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

Access

Post by Damian »

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).

BigRedCat
User
User
Posts: 3
Joined: Fri Dec 28, 2007 3:17 pm
Location: United Kingdom

DDE and Access 2003

Post by BigRedCat »

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

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

Post by Damian »

Laurence

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

Cheers

Damian

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

Post by Damian »

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
User
User
Posts: 5
Joined: Wed Oct 18, 2006 9:45 pm
Location: Cheshire

Access VBA

Post by Damian »

Anyone?

Post Reply