Results 1 to 5 of 5

Thread: data report problem..

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2007
    Posts
    31

    data report problem..

    'i need to view employees record when type in emp id to view that row record
    'please help me. thanks
    ' or i need giv all project code for more infomation ?

    Code:
    Private Sub cmdView_Click()
    
    Dim rs As New ADODB.Recordset
    Dim cn As New ADODB.Connection
    Dim strCNString As String
    
    strCNString = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
    cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
    cn.ConnectionString = strCNString
    
    cn.Open
        With rs
            .Open "SELECT emp_id FROM Employees", cn, adOpenDynamic, adLockOptimistic
             Do Until .EOF
                If !emp_id = txtID.Text Then
                
                intFound = 1
                End If
                .MoveNext
              Loop
              .MoveFirst
              If intFound = 0 Then
                       MsgBox "Employee ID not found !", vbExclamation, "Search"
    
                       txtID.Text = ""
                       With txtID
                           .SelStart = 0
                           .SetFocus
                       End With
              End If
         End With
         
         'i need to view employees record when type in emp id to view thet entire record
         'please help me. thanks
        Dim rsx As New ADODB.Recordset
      
        rsx.Open "SELECT emp_id, position, Fname, Lname, age, dob, gender, address, phone, country, race, Staff_Type, basic_salary, salary_id FROM employees", cnn, adOpenDynamic, adLockPessimistic
        
        With EmpReport
            Set .DataSource = rsx
            
            .Show
        End With
        rsx.Close
    
    End Sub
    Attached Files Attached Files

  2. #2
    Addicted Member
    Join Date
    Jun 2006
    Location
    Virac
    Posts
    129

    Re: data report problem..

    you use this:

    "SELECT * FROM Employees WHERE Emp_ID='" & txt.Text & "'"

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: data report problem..

    If Emp_ID is a character field:
    Code:
    "SELECT * FROM Employees WHERE Emp_ID='" & txtID.Text & "'"
    If Emp_ID is a numeric field:
    Code:
    "SELECT * FROM Employees WHERE Emp_ID=" & txtID.Text
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: data report problem..

    Moved to Reporting

  5. #5
    Registered User RaviIntegra's Avatar
    Join Date
    Mar 2007
    Location
    Pondicherry, India
    Posts
    125

    Re: data report problem..

    vb Code:
    1. mysql = "select * from tablename"
    2. Set DataEnvironment = New DataEnvironment1
    3. DataEnvironment1.Commands(1).CommandText = mysql
    4. DataEnvironment1.Command1
    5. DoEvents
    6. DataReport1.Show

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width