Click to See Complete Forum and Search --> : Searching a Field in MS Access Without Using the "Find" Command


Azrael5
June 15th, 2001, 09:21 AM
I'm in need of a VB script or something which will allow me to perform a search on a particular form field in my MS Access database. I want to be able to simply key a unique value into a field on a form (without changing data in the table behind the form)and have that value returned along with all of the other fields'belonging to that record. I don't want to use the cumbersome MS Access Find command button if I don't have to. EXAMPLE: I have a table with 6 columns. The primay key is the Account Number (unique value). The other fields are: Company Name, Address1, Address2, City, State, Zip. My form which displayes this table has fields for each of these values, including Account Number. I want to be able to click on the Account Number field (on the form), enter the Account Number I'm searching for (without changing the the account number housed in the underlying table), hit enter, and have it return that Account Number along with its associated address info. Then I'd like to be able to repeat this action. Is there some sample code I can look at to do this or can anyone provide an Access-based solution that I may have overlooked?? I'll forever be thankful!!!

vchapran
June 15th, 2001, 01:35 PM
If you use Data Access objects instead of Data Control, your field after you left the record will not be updated. You can use Find method of recordset object to bring the record with Account ID you are interested in. There are tons of samples in MSDN and on Internet to work with ADO library.
Vlad

Robert Moy
June 17th, 2001, 07:35 AM
Hello:

You can use SQL to do it on ADO:

Adodc1.RecordSource = "Select " & Text3.Text & _
" from " & Text4.Text & _
" WHERE " & Text5.Text & "=" & Text6.Text
Adodc1.Refresh

Good Luck