Dim CN As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Rst As New ADODB.Recordset
Dim DeviceCount As Integer
Dim Count As Integer
'Open DB Connection
CN.Open DBPath
Set Rst = New ADODB.Recordset
Rst.CursorType = adOpenDynamic
'---- what is this??? I couldn't find help on it - you don't need it!
'Rst.Supports (adMovePrevious)
'Prepare the user-defined function statement and execute the command.
Cmd.ActiveConnection = CN
Cmd.CommandText = "SELECT DeviceName, DeviceType, CMACNum, Address, PLCID, NumEvents, StartRead, StopRead FROM SOEWFC_Definitions;"
'---- why do ppl execute when its open ?
'- can't remember the options flags ;)
'rst.open strSql,cn,option,option,adcmdtext
Set Rst = Cmd.Execute
'---- being picky - but no checks to see whether the db opened? ;) or the recordset opened ;) rst.state=adstateopen
'Check to see if there are any records in the table
If Rst.EOF = False Then
'get number of rows in Backups table
Rst.MoveLast
DeviceCount = Rst.RecordCount
Rst.MoveFirst
End If