Data Environment help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gillian3114
    New Member
    • Mar 2007
    • 16

    Data Environment help please

    i need to view salary payslip (data report) based on that particular month and year.

    in Data Environment sql :

    SELECT[emp_id], [emp_name], [emp_position], [emp_bs], [month_paid], [year_paid], [total_addition], [gross_pay], [total_deduction], [total_pay] FROM salary WHERE month_paid = ? and year_paid = ?

    parameter is monthler

    parameter is yearler


    in vb code:

    Code:
    Dim intMonth As Integer
    Dim intYear As Integer
    
    ' is a combo box that select month
    
    If cboMonth.ListIndex = 0 Then
        intMonth = 1
    ElseIf cboMonth.ListIndex = 1 Then
        intMonth = 2
    ElseIf cboMonth.ListIndex = 2 Then
        intMonth = 3
    ElseIf cboMonth.ListIndex = 3 Then
        intMonth = 4
    ElseIf cboMonth.ListIndex = 4 Then
        intMonth = 5
    ElseIf cboMonth.ListIndex = 5 Then
        intMonth = 6
    ElseIf cboMonth.ListIndex = 6 Then
        intMonth = 7
    ElseIf cboMonth.ListIndex = 7 Then
        intMonth = 8
    ElseIf cboMonth.ListIndex = 8 Then
        intMonth = 9
    ElseIf cboMonth.ListIndex = 9 Then
        intMonth = 10
    ElseIf cboMonth.ListIndex = 10 Then
        intMonth = 11
    ElseIf cboMonth.ListIndex = 11 Then
        intMonth = 12
    End If
    
     is a combo box that select year
    
    If cboYear.ListIndex = 0 Then
        intYear = 2007
    ElseIf cboYear.ListIndex = 1 Then
        intYear = 2008
    ElseIf cboYear.ListIndex = 2 Then
        intYear = 2009
    ElseIf cboYear.ListIndex = 3 Then
        intYear = 2010
    ElseIf cboYear.ListIndex = 4 Then
        intYear = 2011
    End If
    
    
    
    ' how should i pass a value to a Data Environment sql query ?
    or got other way to do ?
    ' i need view that month and year that i have selected. 
    'P_Payslip.Show
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by gillian3114
    i need to view salary payslip (data report) based on that particular month and year.

    in Data Environment sql :

    SELECT[emp_id], [emp_name], [emp_position], [emp_bs], [month_paid], [year_paid], [total_addition], [gross_pay], [total_deduction], [total_pay] FROM salary WHERE month_paid = ? and year_paid = ?

    parameter is monthler

    parameter is yearler


    in vb code:

    Code:
    Dim intMonth As Integer
    Dim intYear As Integer
    
    ' is a combo box that select month
    
    If cboMonth.ListIndex = 0 Then
        intMonth = 1
    ElseIf cboMonth.ListIndex = 1 Then
        intMonth = 2
    ElseIf cboMonth.ListIndex = 2 Then
        intMonth = 3
    ElseIf cboMonth.ListIndex = 3 Then
        intMonth = 4
    ElseIf cboMonth.ListIndex = 4 Then
        intMonth = 5
    ElseIf cboMonth.ListIndex = 5 Then
        intMonth = 6
    ElseIf cboMonth.ListIndex = 6 Then
        intMonth = 7
    ElseIf cboMonth.ListIndex = 7 Then
        intMonth = 8
    ElseIf cboMonth.ListIndex = 8 Then
        intMonth = 9
    ElseIf cboMonth.ListIndex = 9 Then
        intMonth = 10
    ElseIf cboMonth.ListIndex = 10 Then
        intMonth = 11
    ElseIf cboMonth.ListIndex = 11 Then
        intMonth = 12
    End If
    
     is a combo box that select year
    
    If cboYear.ListIndex = 0 Then
        intYear = 2007
    ElseIf cboYear.ListIndex = 1 Then
        intYear = 2008
    ElseIf cboYear.ListIndex = 2 Then
        intYear = 2009
    ElseIf cboYear.ListIndex = 3 Then
        intYear = 2010
    ElseIf cboYear.ListIndex = 4 Then
        intYear = 2011
    End If
    
    
    
    ' how should i pass a value to a Data Environment sql query ?
    or got other way to do ?
    ' i need view that month and year that i have selected. 
    'P_Payslip.Show
    Just posted the below, gillian3114, greetings...

    Give it a whirl. I also posted another that deals with Data Environment. Will find it for you:

    http://www.google.com/search?q=Data.. .ie7&rlz=1I7SUN A

    +++++++++++++++ +++++++

    Please search a bit deeper here if this is no help. I added "Data Report without Data Environment " to Google to fetch info included there.

    Good luck with the project!

    Dököll

    Comment

    • cmrhema
      Contributor
      • Jan 2007
      • 375

      #3
      Originally posted by gillian3114
      i need to view salary payslip (data report) based on that particular month and year.

      in Data Environment sql :

      SELECT[emp_id], [emp_name], [emp_position], [emp_bs], [month_paid], [year_paid], [total_addition], [gross_pay], [total_deduction], [total_pay] FROM salary WHERE month_paid = ? and year_paid = ?

      parameter is monthler

      parameter is yearler


      in vb code:

      Code:
      Dim intMonth As Integer
      Dim intYear As Integer
      
      ' is a combo box that select month
      
      If cboMonth.ListIndex = 0 Then
          intMonth = 1
      ElseIf cboMonth.ListIndex = 1 Then
          intMonth = 2
      ElseIf cboMonth.ListIndex = 2 Then
          intMonth = 3
      ElseIf cboMonth.ListIndex = 3 Then
          intMonth = 4
      ElseIf cboMonth.ListIndex = 4 Then
          intMonth = 5
      ElseIf cboMonth.ListIndex = 5 Then
          intMonth = 6
      ElseIf cboMonth.ListIndex = 6 Then
          intMonth = 7
      ElseIf cboMonth.ListIndex = 7 Then
          intMonth = 8
      ElseIf cboMonth.ListIndex = 8 Then
          intMonth = 9
      ElseIf cboMonth.ListIndex = 9 Then
          intMonth = 10
      ElseIf cboMonth.ListIndex = 10 Then
          intMonth = 11
      ElseIf cboMonth.ListIndex = 11 Then
          intMonth = 12
      End If
      
       is a combo box that select year
      
      If cboYear.ListIndex = 0 Then
          intYear = 2007
      ElseIf cboYear.ListIndex = 1 Then
          intYear = 2008
      ElseIf cboYear.ListIndex = 2 Then
          intYear = 2009
      ElseIf cboYear.ListIndex = 3 Then
          intYear = 2010
      ElseIf cboYear.ListIndex = 4 Then
          intYear = 2011
      End If
      
      
      
      ' how should i pass a value to a Data Environment sql query ?
      or got other way to do ?
      ' i need view that month and year that i have selected. 
      'P_Payslip.Show
      I have used datareports BUT WITHOUT data environment, and I pass the query in form code itself
      You must be having a control where you will be prompting the user to print report
      Try out the below code in that control

      Dim db_file As String
      Dim Mycon1 As New ADODB.Connectio n
      ' Get the data.
      db_file = App.Path
      If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
      db_file = db_file & "emp.mdb"
      ' Open a connection.
      Mycon1.Connecti onString = _
      "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
      "Data Source=" & db_file & ";" & _
      "Persist Security Info=False"
      Me.Refresh
      Mycon1.Open
      Set m1 = Mycon1.Execute( "SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction , total_pay FROM salary WHERE month_paid = " & intMonth & " and year_paid =" & intYear & "", , adCmdText)
      ' Connect the Recordset to the DataReport.
      Set DataReport1.Dat aSource = m1
      DataReport1.Win dowState = vbMaximized
      DataReport1.Sho w vbModal
      DataReport1.Cap tion = "Invoice"
      m1.Close
      Mycon1.Close
      Mycon1.Open
      Set Mycon1 = Nothing
      End If


      This code works for me
      Good Luck

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #4
        Originally posted by cmrhema
        I have used datareports BUT WITHOUT data environment, and I pass the query in form code itself
        You must be having a control where you will be prompting the user to print report
        Try out the below code in that control

        Dim db_file As String
        Dim Mycon1 As New ADODB.Connectio n
        ' Get the data.
        db_file = App.Path
        If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
        db_file = db_file & "emp.mdb"
        ' Open a connection.
        Mycon1.Connecti onString = _
        "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
        "Data Source=" & db_file & ";" & _
        "Persist Security Info=False"
        Me.Refresh
        Mycon1.Open
        Set m1 = Mycon1.Execute( "SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction , total_pay FROM salary WHERE month_paid = " & intMonth & " and year_paid =" & intYear & "", , adCmdText)
        ' Connect the Recordset to the DataReport.
        Set DataReport1.Dat aSource = m1
        DataReport1.Win dowState = vbMaximized
        DataReport1.Sho w vbModal
        DataReport1.Cap tion = "Invoice"
        m1.Close
        Mycon1.Close
        Mycon1.Open
        Set Mycon1 = Nothing
        End If


        This code works for me
        Good Luck
        Good job, cmrhema!

        Here is the link I was looking for, gillian3114. You can query your database and furnish a report:



        Give above time to load, snapshots included. Continue asking questions, we'll ge there...

        Take cmrhema also, see how that works for you.

        Comment

        • vijaydiwakar
          Contributor
          • Feb 2007
          • 579

          #5
          Originally posted by cmrhema
          I have used datareports BUT WITHOUT data environment, and I pass the query in form code itself
          You must be having a control where you will be prompting the user to print report
          Try out the below code in that control

          Dim db_file As String
          Dim Mycon1 As New ADODB.Connectio n
          ' Get the data.
          db_file = App.Path
          If Right$(db_file, 1) <> "\" Then db_file = db_file & "\"
          db_file = db_file & "emp.mdb"
          ' Open a connection.
          Mycon1.Connecti onString = _
          "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
          "Data Source=" & db_file & ";" & _
          "Persist Security Info=False"
          Me.Refresh
          Mycon1.Open
          Set m1 = Mycon1.Execute( "SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction , total_pay FROM salary WHERE month_paid = " & intMonth & " and year_paid =" & intYear & "", , adCmdText)
          ' Connect the Recordset to the DataReport.
          Set DataReport1.Dat aSource = m1
          DataReport1.Win dowState = vbMaximized
          DataReport1.Sho w vbModal
          DataReport1.Cap tion = "Invoice"
          m1.Close
          Mycon1.Close
          Mycon1.Open
          Set Mycon1 = Nothing
          End If


          This code works for me
          Good Luck
          Nice answer so far
          keep it up

          Comment

          • gillian3114
            New Member
            • Mar 2007
            • 16

            #6
            Error: Object Requiered.

            Code:
            Dim intMonth As Integer
            Dim intYear As Integer
            
            If cboMonth.ListIndex = 0 Then
                intMonth = 1
            ElseIf cboMonth.ListIndex = 1 Then
                intMonth = 2
            ElseIf cboMonth.ListIndex = 2 Then
                intMonth = 3
            ElseIf cboMonth.ListIndex = 3 Then
                intMonth = 4
            ElseIf cboMonth.ListIndex = 4 Then
                intMonth = 5
            ElseIf cboMonth.ListIndex = 5 Then
                intMonth = 6
            ElseIf cboMonth.ListIndex = 6 Then
                intMonth = 7
            ElseIf cboMonth.ListIndex = 7 Then
                intMonth = 8
            ElseIf cboMonth.ListIndex = 8 Then
                intMonth = 9
            ElseIf cboMonth.ListIndex = 9 Then
                intMonth = 10
            ElseIf cboMonth.ListIndex = 10 Then
                intMonth = 11
            ElseIf cboMonth.ListIndex = 11 Then
                intMonth = 12
            End If
            
            If cboYear.ListIndex = 0 Then
                intYear = 2007
            ElseIf cboYear.ListIndex = 1 Then
                intYear = 2008
            ElseIf cboYear.ListIndex = 2 Then
                intYear = 2009
            ElseIf cboYear.ListIndex = 3 Then
                intYear = 2010
            ElseIf cboYear.ListIndex = 4 Then
                intYear = 2011
            End If
            
            Dim Mycon1 As New ADODB.Connection
            Dim m1 As New ADODB.Recordset
            Dim strCNString As String
            
            strCNString = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
            Mycon1.Provider = "Microsoft Jet 4.0 OLE DB Provider"
            Mycon1.ConnectionString = strCNString
            Mycon1.Open
            
                Set m1 = Mycon1.Execute("SELECT emp_id, emp_name, emp_position, emp_bs, month_paid, year_paid, total_addition, gross_pay, total_deduction, total_pay FROM salary ", , adCmdText)
            ' Connect the Recordset to the DataReport.
            
                Set DataReport1.DataSource = m1 ' error: object required
                
               
                DataReport1.WindowState = vbMaximized
                DataReport1.Show vbModal
                DataReport1.Caption = "Invoice"
                m1.Close
                Mycon1.Close
                Mycon1.Open
                Set Mycon1 = Nothing

            Comment

            • vijaydiwakar
              Contributor
              • Feb 2007
              • 579

              #7
              Originally posted by gillian3114
              Error: Object Requiered.

              [CODE]
              pls sho the place where u got the error

              Comment

              • gillian3114
                New Member
                • Mar 2007
                • 16

                #8
                error occur at:


                Set DataReport1.Dat aSource = m1

                Comment

                • cmrhema
                  Contributor
                  • Jan 2007
                  • 375

                  #9
                  Originally posted by gillian3114
                  error occur at:


                  Set DataReport1.Dat aSource = m1
                  Sorry Gillian for the trouble
                  Fogot to tell you that one should Declare m1 intially
                  Dim m1 As New ADODB.Recordset

                  Comment

                  • Arvindkumar
                    New Member
                    • May 2007
                    • 3

                    #10
                    Hello All

                    I have the similar problem in data environment. Though the code works well to set the data source with report.

                    How can I show the data in Reports. Say I have text1 as a text box in report and I want to display the data in the textbox.

                    Also I want to display all the records that matching the criteria :
                    say
                    select * from emp where sal >5000

                    Please help I am in trouble

                    Thanks

                    Comment

                    • Dököll
                      Recognized Expert Top Contributor
                      • Nov 2006
                      • 2379

                      #11
                      Originally posted by Arvindkumar
                      Hello All

                      I have the similar problem in data environment. Though the code works well to set the data source with report.

                      How can I show the data in Reports. Say I have text1 as a text box in report and I want to display the data in the textbox.

                      Also I want to display all the records that matching the criteria :
                      say
                      select * from emp where sal >5000

                      Please help I am in trouble

                      Thanks
                      Greetings and salutations, Arvindkumar!

                      Get a load of this link here found through Google:



                      Use this to get an idea how to modify your code to do what you need.

                      Please write if you are still uncertain.

                      In a bit, and good luck...

                      Dököll

                      Comment

                      Working...