I found a project online and does everything that i wanted with the exception of one minor thing. I don't know how to change the table from Customers to Orders. I can change it in the code and in the form, but it still doesn't work. The fields that I wanted to display are: employee, ship company,and ship via. When I made the changes to the code for the Orders table, it would display only the ship via and nothing else. I pasted the original code that uses the Customer table. If someone is able to help me, I will greatly appreciate it.
Private Sub Command1_Click()
On Error GoTo OOPS
Dim My_Query As String
'The database KNOWS if a field is numeric or not
'IF the field you are trying to search is a string
'then you must enclose it with "MySting" or 'Mystring'
'Otherwise if the value is numeric, then the database
'expects a query like WHERE CustomerID=1
'and NOT! WHERE CustomerID='1'
'otherwise it crashes with an error
Data1.RecordSource = "SELECT * FROM Customers WHERE " & MyQuery
'This just means:
' If the search is positive, i want you to return me all
' fields "SELECT" "*", and now i want you to
' search the table "Customers" "WHERE" the entry
' "Cbo_Category"'is equal to "Cbo_Operator" what i said
'We need to move to the last entry and back to the first
'or else we get a wrong record count, this is a bug i think.
MsgBox Data1.Recordset.RecordCount & " matches found."
MsgBox "No Records Found"
Private Sub Form_Load()
MsgBox "If you use the LIKE method, then you can use the *(wildcard) to complete the query." & vbNewLine & "Like do a search for Ma* or M*ria or *m* etc."
'Change this to where your NWIND.MDB is installed
'This DB ships by default with vb5 and 6
Data1.DatabaseName = "C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB"
Cbo_Category.ListIndex = 0
Cbo_Operator.ListIndex = 0