CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2001
    Posts
    3

    Searching a Field in MS Access Without Using the "Find" Command

    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!!!


  2. #2
    Join Date
    Aug 2000
    Location
    NY, USA
    Posts
    632

    Re: Searching a Field in MS Access Without Using the "Find" Command

    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


  3. #3
    Join Date
    Feb 2001
    Posts
    54

    Re: Searching a Field in MS Access Without Using the "Find" Command

    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



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