Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33
  1. #16
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    Sorry Ajax, I should have said Combobox not texbox. I think your second sentence is correct, that it's searching the ID column (1), rather than column 2 where the actual AssetName is. To fix this, should I direct the VBA to read:

    Me.Filter = "AssetNameFK.Column(2) LIKE '*"& Me.txtSearch &"*'"

    Actually, I just ran this and it threw up an error:

    Click image for larger version. 

Name:	error 3709.jpg 
Views:	15 
Size:	9.2 KB 
ID:	35187


    Click image for larger version. 

Name:	error.jpg 
Views:	15 
Size:	11.4 KB 
ID:	35188

  2. #17
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    blank. unable to delete.

  3. #18
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    no, would be a lot easier if you made your textbox a combo box, same as assetnamefk but unbound rather than bound

  4. #19
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    converted to combobox. Still no joy. Same error.

  5. #20
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you took the .column off?

  6. #21
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    No, I left it in.

  7. #22
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you need to take it off

  8. #23
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    Hi Ajax, I wasn't sure if you meant the .Column and leave (2), or both. I still got an error.

    Click image for larger version. 

Name:	Ashampoo_Snap_2018.08.22_19h16m34s_013_.jpg 
Views:	10 
Size:	11.1 KB 
ID:	35199

  9. #24
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    sigh - remove the (2) as well

  10. #25
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    Sorry Ajax, I really appreciate yours and other's help. I will find this answer soon enough. Ok. Let me start from the very beginning and map out the pieces, then we'll start writing code.

    What I Have:

    tblTradeData 'Record Source to frmTradeEntry
    frmTradeEntry
    ComboBox - AssetNameFK 'displaying column2 text. column1 is hidden which has the unique ID from its table tblAssetName.
    Text Box- txtSearch 'in form header
    Button - btnSearch 'in form header

    Ok. If someone can guide me through writing this VBA, I'll see if this can be nailed. The opening code is below. What should be written first so I can understand why. Thanks anyone who might assist.



    Private Sub btnSearch_Click()






    End Sub

  11. #26
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    so, for the purposes of this thread, you have two tables - tblTradeData and tblAssetName which have a relationship between AssetNameFK in tblTradeData and AssetNamePK? in tblAssetName. Both the PK and FK are Long number types.

    Please clarify what the search is supposed to achieve. Using Like implies you expect to potentially return multiple records. Your form is a single form (per post #14) so you want the user to move from one record to another until they find the one they want - perhaps based on some factor other than a partial match on a name. Is this correct? or is it something else?

  12. #27
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    Yes, you're exactly correct with both sentences.

    in tblAssetName PK is number - Long Integer, as is FK in tblTradeData.

    I would like to create search filter box in the form header where I can type a string of letters which will dynamically search the ComboBox AssetNameFK (in fact, the whole form) and filter the results, exactly as I can with the default Access search window per the screenshot below. But I would like a larger version of this in the form header. Then I can just scroll down through each record at the results, as it does now using the default search.

    Click image for larger version. 

Name:	search.jpg 
Views:	8 
Size:	4.2 KB 
ID:	35200

    It kills me because I saw a video a few years ago achieving exactly this, and for the life of me, can't find it anywhere.

  13. #28
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  14. #29
    DigitalAdrenaline is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2012
    Posts
    100
    Orange, I'm actually a fan of Steve Bishop and originally had watched his videos to get into Access. I was also just now seeing if he had an email address to possibly ask him. I can't remember if the original video I saw was one of his or another person creating a hotel management program that I remember. I've seen a couple of Steve's keyword search tutes, but wasn't the one I remember. I've watched the one in your link where he creates a Query linked to an embedded form. If all else failed, i was going to try that path but preferred the original video that's lost in memory.

  15. #30
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    in that case your approach needs to be completely different. The actions required are:

    1. search tblAssetName for a list of partial matches on name
    2. note all the different related PK values
    3. apply these values as a filter against the FK in your form


    Code:
    Private Sub btnSearch_Click()
    dim rst as dao.recordset
    dim db as dao.database
    dim fltrStr as string
    
    '1. search tblAssetName for a list of partial matches on name
    set db=currentdb
    set rst=db.openrecordset("SELECT AssetNamePK FROM tblAssetName WHERE AssetName LIKE '*" & txtSearch & "*'")
    
    '2. note all the different related PK values
    fltrstr=""
    while not rst.eof
        fltrStr=fltrStr & "," & rst!AssetNamePK
        rst.movenext
    wend
    rst.close
    set rst=nothing
    
    '3. apply these values as a filter against the FK in your form
    if fltrStr<>"" then 
        me.filter="AssetNameFK IN (" & mid(fltrStr,2) & ")"
        me.filteron=true
    end if
    
    set db=nothing
    
    End Sub

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Keyword or fragment search
    By orange in forum Sample Databases
    Replies: 0
    Last Post: 01-23-2015, 02:47 PM
  2. keyword search
    By Mbakker71 in forum Access
    Replies: 5
    Last Post: 02-05-2014, 06:03 AM
  3. keyword search in a combo box
    By pbouk in forum Forms
    Replies: 9
    Last Post: 05-30-2013, 09:45 PM
  4. Multiple Keyword Search
    By gatsby in forum Access
    Replies: 15
    Last Post: 01-21-2013, 10:53 PM
  5. Making a keyword search
    By timmy in forum Forms
    Replies: 9
    Last Post: 03-14-2011, 02:57 AM

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