Function GetPastDueRQ(sPN As String, Optional sNG As String = "") As Integer
'SkipVought/2007 Sep 06/
'--------------------------------------------------
' Access: DWPROD.FRH_MRP.READ
'--------------------------------------------------
':this function returns Past Due Requirements for a given PN and optional NG
'--------------------------------------------------
Dim sConn As String, sSQL As String, sServer As String
Dim rst As ADODB.Recordset, cnn As ADODB.Connection
Set cnn = New ADODB.Connection
sServer = "dwprod"
cnn.Open "Driver={Microsoft ODBC for Oracle};" & _
"Server=" & sServer & ";" & _
"Uid=/;" & _
"Pwd="
Set rst = New ADODB.Recordset
sSQL = "SELECT Sum(RQQTY_275) "
sSQL = sSQL & "FROM FRH_MRP.PSK02275_OPEN "
sSQL = sSQL & "WHERE PARTNO_201 like '" & Trim(sPN) & "'"
sSQL = sSQL & " AND RQDATE8_275 <'" & Format(Date, "yyyymmdd") & "'"
If sNG <> "" Then
sSQL = sSQL & " AND NETGRP_275 ='" & sNG & "'"
End If
Debug.Print sSQL
rst.Open sSQL, cnn, adOpenStatic, adLockReadOnly, adCmdText
rst.MoveFirst
GetPastDueRQ = rst(0)
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Function