Click to See Complete Forum and Search --> : Please I need help tonight


February 14th, 2000, 11:28 PM
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

chem1
February 15th, 2000, 12:19 AM
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.

ChrisDIllon
February 15th, 2000, 01:04 AM
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

chem1
February 15th, 2000, 01:41 AM
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.

ChrisDIllon
February 15th, 2000, 03:03 AM
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.