CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Guest

    Please I need help tonight

    I have a program where I want to search for either an employee id, last name or state. Doing that is not the problem, what I want to know is if the search results can be displayed in a datagrid. If not, I know I can make the results display in a listbox, but I would then need to pass the selected listbox index to the form. I have a search set up now that will search through the recordset and and display the first record matching the search criteria in the controls on the form, but if there are more than 1 record that matches the search criteria, the user can not view the results of the second record found and on. Could sombody please help me, my assignment is due on Wednesday, February 16,2000. Thanks in advance






  2. #2
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Re: Please I need help tonight

    Have you tried putting the Recordsource property of the ADO Control to the SQL Statement.
    I foyu have not done this then send me your code and I can go through it.


  3. #3
    Join Date
    Feb 2000
    Posts
    3

    Re: Please I need help tonight

    I tried to send a message, I got an error.
    Let me give the form layout:

    The search form has 3 sets of option buttons, text boxes, and search buttons, one for each field to search.

    If you can help me out on this, I would appreciate it.

    This is the code in one of the search buttons:

    Dim strSearch As String
    'Input box for user to enter a search string
    strSearch = txtID.Text
    strSearch = "Employeeid='" & strSearch & "'"
    Maintenance.adoShely.Recordset.MoveFirst
    Maintenance.adoShely.Recordset.Find strSearch, , adSearchForward, 1
    If Maintenance.adoShely.Recordset.EOF Then
    MsgBox "Employee not found.", vbOKOnly, "Search"
    Maintenance.adoShely.Recordset.MoveFirst
    End If
    Search.Hide




  4. #4
    Join Date
    Aug 1999
    Location
    Pakistan
    Posts
    366

    Re: Please I need help tonight

    OK try this:


    private Sub Command1_Click()
    Dim sql as string
    Adodc1.CommandType = adCmdText
    sql = "Select * from Authors Where Au_ID= " & Val(Text1)
    Adodc1.RecordSource = sql
    Adodc1.Refresh
    End Sub




    USe MS ADO Control (OLEDB) and MS DataGrid Control(OLEDB)

    Set the datasource property of datagrid to ADODC1
    Right Click on Datagrid and Click Retrieve Fields

    I hope this works.

    NOte: This will show the required data in the grid
    if you want to revert to ALL the data back then put a command button and put ADODC1.Refresh code behind it.Set the caption to REFRESH or whatever u like.



  5. #5
    Join Date
    Feb 2000
    Posts
    3

    Re: Please I need help tonight

    The SQL statement for the record source isn't valid. I have to define the datasource for the datagrid and I get an error unless I enter a correct SQL statement in the data controls record source.


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

Featured