Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2004
    Posts
    6

    Unanswered: Matching 2 fields in open form control button

    Hello all, I am fairly new to Access and have stumbled on a small problem. I have a table in my database with two fields, one is "Part_Number" and the other is "Alternate_Number", there are also some other fields that describe the unit. What I currently have is a form that will allow you to search for a part number and display it in a form called "Part Search Results". This is currently being done with the control button wizard to open a form and match two fields. I would like to be able to enter in a number in the part search field and then have it query the database to find all records that are matching the "Part_Number" and "Alternate_Number" fields. Then open the "Part Search Results" form.

  2. #2
    Join Date
    Sep 2003
    Posts
    228
    You want to search for number X in both the "Part_Number" and "Alternate_Number" fields?

    Do you want to find records where both part number and alternate number are = X or where either number is = to X?

  3. #3
    Join Date
    Nov 2004
    Posts
    6
    I want to search for number X in both the "Part_Number" and "Alternate_Number" fields?

  4. #4
    Join Date
    Sep 2003
    Posts
    228
    in the WHERE clause of your query you can put the condition part_number = X or alt_number = X

  5. #5
    Join Date
    Nov 2004
    Posts
    6
    I'm fairly good with SQL, but when I use the Control Button wizard to make a button to open a form it does not ask me for SQL. It instead asks me to choose a field from the two tables and make them equal. I have played around with the event procedure in VB to allow wildcard searches, and have tried to put in a sort of "where" clause but no luck.

    What I basically want is a button that will open up a form after it queries the table based on the input, but it needs to search two fields in the table.

  6. #6
    Join Date
    Sep 2003
    Posts
    228
    When you open this new form, you can put your query in the form's record source via VB code.

    Inside the form's onopen event:
    form1.recordsource = "SELECT [field1], [field2] FROM [Table1] WHERE [field1] = X OR [field2] = X"
    form1.requery

    Are you familiar with VB?

  7. #7
    Join Date
    Nov 2004
    Posts
    6
    Not really, but I'm sure I can figure it out from youe example. Thanks alot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •