Private Sub Workbook_Open()
On Error GoTo err_Workbook_Open
'Controleer de regels en maak een afdruk
SubCheckOrders
'Sluit alles af
SubCloseWb
On Error GoTo 0
Exit Sub
err_Workbook_Open:
Resume Next
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''
'Controleer de regels en maak een afdruk
Sub SubCheckOrders()
On Error GoTo err_CheckOrders
sConnString = "Provider=SQLOLEDB;Data Source=CompXDCSQL01;" & _
"Initial Catalog=CompXCommon;" & _
"Integrated Security=SSPI;"
' Create the Connection and Recordset objects.
Set Conn = New ADODB.Connection
Set Rs1 = New ADODB.Recordset
' Open the connection and execute.
Conn.Open sConnString
'Open recordset
strQuery1 = "SELECT * FROM Orders Where OrdStat = 1 order by OrderId"
Set Rs1 = Conn.Execute(strQuery1)
' Check we have data.
If Rs1.EOF Then
' Close the recordset
MsgBox "Error: No records returned.", vbCritical
Exit Sub
End If
While Not Rs1.EOF
'Doorloop recorset
blnPrintBon = False
If Rs1!OrderActive = True Then
Rs1_OrderId = Rs1!OrderId
'Hierna komen een aantal controles waaraan het order moet voldoen
If ....... then
blnPrintBon = True
End if
If blnPrintBon = True Then
blnstatus = fnctPrintBon(Rs1_OrderId)
If blnstatus = True Then
Call SubUpdate_Status(Rs1_OrderId)
strQuery1 = "SELECT * FROM Orders Where OrdStat = 1 and OrderId >= " & Rs1_OrderId & " order by OrderId"
Set Rs1 = Conn.Execute(strQuery1)
End If
End If
Read_Next_Record:
Rs1.MoveNext
Wend
' MsgBox "Klaar"
'
' Clean up
Rs1.Close
If CBool(Conn.State And adStateOpen) Then Conn.Close
Set Conn = Nothing
Set Rs1 = Nothing
On Error GoTo 0
Exit Sub
err_CheckOrders:
fnctSendError 0, "Error in " & Me.Name & "- CheckOrders: (" & Err.Number & ") - " & Err.Description
' MsgBox "CheckOrders: (" & Err.Number & ") - " & Err.Description
Resume Next
End Sub
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''
Sub SubCloseWb()
Application.DisplayAlerts = False
With ThisWorkbook
.Saved = False
.Close
End With
End Sub