The first button: cmdPwrOn grabs the communications data from the
subform/record, and sends the correct "CODE" to an Overhead Projector, or TV
device via a serial cable. Each record in the table is a specific DEVICE to
control. (Currently only turning the device ON or OFF)
So each subform has an ON button & OFF button, along with two LED images that
go red or green.
On the Main Form, I have an ALL ON button & ALL OFF button, that needs to
click each of the individual ON or OFF buttons at once, but only for the
subforms that are "ACTIVE"?
Here is a link to view the Main Form w/10 Active subforms:
http://cerberus.clearwave.com/jerry/PCM_Main_Form.jpg
Heres the code behind a cmdPwrOn button:
-------------------------------------------
Public Sub cmdPowerOn_Click()
'******** Turn on the Green Power On LED image icon ********
Me.ImageOn.Visible = True
Me.ImageOff.Visible = False
'******** Assign Com Port Settings and Values to variables and Send Power On
command code to device ********
'******** Assign Com Port and Com Settings from subForm record data to String
Variables
Dim strCommPort As Integer
Dim strCommSettings As String
strCommPort = Chr(34) & Me.txtConCom & Chr(34)
strCommSettings = Chr(34) & Me.txtConBau & "," & Me.txtConPar & "," & Me.
txtConDat & "," & Me.txtConSto & Chr(34)
'******** Send the Command Code to the Serial Device in either ASCII or HEX
Select Case Me.txtOptionAsciiHex
Case Is = 1
XMCommCRC1.InBufferCount = 0 'Flush the Buffer
If (Not XMCommCRC1.PortOpen) Then
Dim Instring As String ' Buffer to hold input string
XMCommCRC1.CommPort = strCommPort ' Use Com Port variables from
subform.
XMCommCRC1.Settings = strCommSettings ' Use baud, parity, data,
and stop bit from variables subform.
'XMCommCRC1.InputLen = 0 ' Tell the control to read entire buffer
when Input is used.
XMCommCRC1.PortOpen = True ' Open the port.
XMCommCRC1.Output = Me.txtConPwrOn & vbCr ' Send the ON command
to the device. Ensure that the device responds with "OK".
'Buffer$ = Buffer$ & XMCommCRC1.InputData ' Wait for data to come
back to the serial port.
'MsgBox "SMS Port Open", vbOKOnly, "Port State"
XMCommCRC1.PortOpen = False
Else
'MsgBox "Port Already Open, It is now closing, and will re-open",
vbOKOnly, "Port State"
XMCommCRC1.PortOpen = False
'XMCommCRC1.PortOpen = True
Call cmdPowerOn_Click
End If
Case Is = 2
XMCommCRC1.InBufferCount = 0 'Flush the Buffer
If (Not XMCommCRC1.PortOpen) Then
Dim Instring As String ' Buffer to hold input string
XMCommCRC1.CommPort = strCommPort ' Use Com Port variables from
subform.
XMCommCRC1.Settings = strCommSettings ' Use baud, parity, data,
and stop bit variables from subform.
'XMCommCRC1.InputLen = 0 ' Tell the control to read entire buffer
when Input is used.
XMCommCRC1.PortOpen = True ' Open the port.
XMCommCRC1.Output = Chr$(2) & Me.txtConPwrOn & Chr$(3) & vbCr '
Send the ON command to the device. Ensure that the device responds with "OK".
'Buffer$ = Buffer$ & XMCommCRC1.InputData ' Wait for data to come
back to the serial port.
'MsgBox "SMS Port Open", vbOKOnly, "Port State"
XMCommCRC1.PortOpen = False
Else
'MsgBox "Port Already Open, It is now closing, and will re-open",
vbOKOnly, "Port State"
XMCommCRC1.PortOpen = False
'XMCommCRC1.PortOpen = True
Call cmdPowerOn_Click
End If
End Sub
-----------------------------------------------
Thanks..
[quoted text clipped - 10 lines]