Results 1 to 12 of 12
  1. #1
    russdwright is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    30

    Exclamation Search based on Text Box Entry

    I have a form based on a table called 'fAppInfo'. In it are the following fields:

    AssetID (PK)
    AppName
    CIID
    Contact1
    Contact2
    Contact3
    Contact1Email
    Contact2Email


    Contact3Email
    Contact1Phone
    Contact2Phone
    Contact3Phone

    I would like to have these fields remain blank on the form until I input the Asset ID and either click on a Search button or press Enter. Right now, all it does is scream at me since it thinks I'm trying to change the value.

    I was able to setup a Combo Box but I'd rather not have someone looking through a list of (right now) 360 entries.

    Any advice/input is appreciated!

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Do you want the user to select a record based on the Asset ID? Will they know what it is?

    Make an unbound combobox for the id, then in the AfterUpdate event:
    Me.Filter="AssetID=" & Me!cmbAssetID
    Me.FilterOn=True
    Me.Requery

    In the OnOpen event for the form:
    DoCmd.GoToRecord,,acNewRec

  3. #3
    russdwright is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    30
    OK, that seems to work somewhat. Now, I need the other fields to load based on what I enter as the AssetID.

    And, to answer your question: yes, they will know what the AssetID is.

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The fields need to be bound to the record source, then when you filter to that record the data will show.

  5. #5
    russdwright is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    30
    Quote Originally Posted by aytee111 View Post
    The fields need to be bound to the record source, then when you filter to that record the data will show.
    By Record Source, you mean Control Source?

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    "Bound" fields have a value in their control source which matches a field in the form's record source.

  7. #7
    russdwright is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    30
    I have those already setup, but when I select/enter a known AssetID nothing loads

  8. #8
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Not possible! If you open the table and filter on an asset id then the record shows. You are doing the same thing here, filtering on a value. Post your code. Are you using the right field name for the filter?

  9. #9
    russdwright is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    30
    OK, I had the wrong labels entered.

    Do I enter "DoCmd.GoToRecord,,acNewRec" directly into the event, or do I use one of the builders to enter this code?

  10. #10
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Type it in directly - from Properties > OnOpen > [Event Procedure] > click the 3 dots to take you into VBA. Typing it will ensure that the correct syntax is followed (for instance the correct number of commas).
    Last edited by aytee111; 10-06-2017 at 07:53 AM. Reason: clarification

  11. #11
    russdwright is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    30
    OK, that got it! Thanks! Still not a fan of using the ComboBox (wanted a text box with a Search button), but it works smoothly enough.

  12. #12
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Keep on using them, you will find that the three lines of code required for a combobox is far simpler than buttons and boxes and all the code that those require. The only time a text box is better is when a user enters a partial entry, such as Smith. However, the filter code will go in the AfterUpdate event, no button needed.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Search Query Based on Multiple Combo / Text Boxes
    By ItsJustRey in forum Queries
    Replies: 5
    Last Post: 07-20-2016, 02:04 PM
  2. Replies: 7
    Last Post: 03-05-2015, 07:34 AM
  3. Search Box Incorrect Entry
    By libraccess in forum Forms
    Replies: 2
    Last Post: 01-01-2014, 03:52 PM
  4. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  5. Replies: 2
    Last Post: 05-20-2013, 05:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums