hi..i have this code for creating a report ...is it possible if i limit my query to those Employee that has a transaction only?? this code returns all the employee records even the ones without transactions....
Code:Private Sub Command1_Click() If cmbselect.Text = "EMPLOYEES" Then 'this shows the preview window for the report DataReport1.Show vbModal 'DataReport1.Refresh ElseIf cmbselect.Text = "CUSTOMERS" Then DataReport2.Show vbModal 'DataReport2.Refresh ElseIf cmbselect.Text = "UTILITIES" Then DataReport3.Show vbModal ' DataReport3.Refresh ElseIf cmbselect.Text = "SUPPLIERS" Then DataReport4.Show vbModal ' DataReport4.Refresh End If End Sub ' ============= DATAREPORT1 ============== Private Sub DataReport_Initialize() Dim strSQL As String Dim strTo As String Dim strFrom As String Dim oConn As New ADODB.Connection Dim oRS As New ADODB.Recordset oConn.CursorLocation = adUseClient oConn.ConnectionString = DataEnvironment1.Connection1 ' were going use this because it's already done, but you could make your own. oConn.Open With frmEmpRep strTo = .DTPicker1.Value strFrom = .DTPicker2.Value End With DataReport1.Sections("Section2").Controls("lbldate").Caption = strTo strSQL = "SHAPE { " strSQL = strSQL & "SELECT tblEmployee.* FROM tblEmployee WHERE Type LIKE 'Employee' " strSQL = strSQL & "} AS Command1 " strSQL = strSQL & "APPEND ({ " strSQL = strSQL & "SELECT tblTransaction.* FROM tblTransaction " strSQL = strSQL & "WHERE DateTrans " strSQL = strSQL & "BETWEEN #" & strFrom & "# " strSQL = strSQL & "AND #" & strTo & "# ORDER BY BALANCE DESC " strSQL = strSQL & "} AS Command2 " strSQL = strSQL & "RELATE 'ID' TO 'ID') " strSQL = strSQL & "AS Command2 " oRS.Open strSQL, oConn, adOpenForwardOnly Set DataReport1.DataSource = oRS End Sub






but willing to dig on facts!
Reply With Quote