|
|
| Author |
Message |
BigRedCat User

Joined: 28 Dec 2007
Posts: 3
Location: United Kingdom
|
Posted: Mon Dec 31, 2007 9:50 am Post subject: DDE data logging and Access 2003 |
|
|
| 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? |
|
| Back to top |
|
 |
BigRedCat User

Joined: 28 Dec 2007
Posts: 3
Location: United Kingdom
|
Posted: Mon Dec 31, 2007 1:05 pm Post subject: Sorted problem |
|
|
| 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. |
|
| Back to top |
|
 |
Damian Active User

Joined: 18 Oct 2006
Posts: 5
Location: Cheshire
|
Posted: Sun Feb 17, 2008 3:05 pm Post subject: Access |
|
|
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). |
|
| Back to top |
|
 |
BigRedCat User

Joined: 28 Dec 2007
Posts: 3
Location: United Kingdom
|
Posted: Mon Feb 25, 2008 3:01 pm Post subject: DDE and Access 2003 |
|
|
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 |
|
| Back to top |
|
 |
Damian Active User

Joined: 18 Oct 2006
Posts: 5
Location: Cheshire
|
Posted: Mon Feb 25, 2008 3:15 pm Post subject: |
|
|
Laurence
Thank you for the code - I'll try it out later tonight
Cheers
Damian |
|
| Back to top |
|
 |
Damian Active User

Joined: 18 Oct 2006
Posts: 5
Location: Cheshire
|
Posted: Thu Mar 06, 2008 6:08 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
Damian Active User

Joined: 18 Oct 2006
Posts: 5
Location: Cheshire
|
Posted: Sat Mar 15, 2008 1:57 pm Post subject: Access VBA |
|
|
| Anyone? |
|
| Back to top |
|
 |
|