Option Explicit
Public X As String
Private Sub DataReport_Initialize()
'Dimming of variables used.
Dim strSQL As String 'SQL String.
Dim oConn As New ADODB.Connection 'New ADODB Connection.
Dim oRS As New ADODB.Recordset 'New ADODB Recordset
Dim BarCode As String
'Connection string
oConn.CursorLocation = adUseClient
oConn.ConnectionString = "Provider=MSDASQL.1;Password=tmm;Persist Security Info=True;User ID=sysprogress;Password=PASSWORD;Data Source=tmm_db10" 'Connection String.
oConn.Open
'Below checks to see which criteria was checked, then runs the SQL query
'Based on the criteria..
'Changes the title and caption of the report to show the date range.
strSQL = "SELECT DISTINCT pub.fin.""Station"", pub.blq.""Item-code"", pub.blq.""Item-desc-2"", pub.iix.""Item-desc-1"" "
strSQL = strSQL & "FROM pub.fin, pub.iix, pub.bmq, pub.blq, pub.ssd "
strSQL = strSQL & "WHERE pub.fin.""Station"" <> 'TUMBLE' AND "
strSQL = strSQL & "pub.fin.""Station"" <> 'ZZZMPI' AND "
strSQL = strSQL & "pub.fin.""Station"" < 'I' AND "
strSQL = strSQL & "pub.fin.""Job"" = pub.ssd.""Job"" AND "
strSQL = strSQL & "pub.fin.""Item-code-mfgd"" = pub.bmq.""Item-code"" AND "
strSQL = strSQL & "pub.bmq.""Branch"" = 'MPI' AND "
strSQL = strSQL & "pub.bmq.""Quote-type"" = 2 AND "
strSQL = strSQL & "pub.bmq.""Quote-set"" = 1 AND "
strSQL = strSQL & "pub.blq.""Master-item-code"" = pub.bmq.""Item-code"" AND "
strSQL = strSQL & "pub.blq.""Master-branch"" = pub.bmq.""Branch"" AND "
strSQL = strSQL & "pub.blq.""Master-quote-type"" = pub.bmq.""Quote-type"" AND "
strSQL = strSQL & "pub.blq.""Master-quote-set"" = pub.bmq.""Quote-set"" AND "
strSQL = strSQL & "pub.blq.""Element"" = 'FORM' AND "
strSQL = strSQL & "pub.iix.""Item-code"" = pub.blq.""Item-code"" "
strSQL = strSQL & "ORDER BY pub.fin.""Station"", pub.fin.""schedule-order"" "
'Connecting...
Debug.Print strSQL
oRS.Open strSQL, oConn, adOpenForwardOnly
'Connection made.
Set rptDataReport.DataSource = oRS
End Sub