Results 1 to 3 of 3
  1. #1
    gbolsover is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Nov 2016
    Posts
    2

    Unhappy Wildcard only effective on first word of text field.

    Straight to the point - I have a form built, based on a table of master data, that has a search box at the top -

    So far I have this working to search for key values, names with wildcard capability, and project names with wildcard capability -

    The issue I'm having is when searching for ANY WORD in the project name, it's only working on the first word of the field.
    Code as follows -

    Private Sub btnSearch_Click()
    DoCmd.OpenForm "frmViewRecord", , , "[DKey]='" & Me.txtKeywords & "' OR [SIARef]='" & Me.txtKeywords & "' OR [ProjectName] like'" & Me.txtKeywords & "*' OR [TransitionManager] like'" & Me.txtKeywords & "*'"


    If IsNull(Me.txtKeywords) Then
    MsgBox "Please type in your search keyword."
    Me.txtKeywords.SetFocus
    End If
    End Sub

    Everything works fine - I have no errors - I just can't get it to search anything other than the first word of the project name, so for example, there's a project called "Project Lotus". If I search 'pro' it finds it, if I search 'lotus', NOTHING.

    I have searched and searched, and every solution has caused me to get errors, e.g.

    DoCmd.OpenForm "frmViewRecord", , , "[DKey]='" & Me.txtKeywords & "' OR [SIARef]='" & Me.txtKeywords & "' OR [ProjectName] like ""*" '" & Me.txtKeywords & "*' OR [TransitionManager] like'" & Me.txtKeywords & "*'"

    The additional wildcard ""*" was suggested, and I've fiddled around with this for a while now, and I get nothing but errors, e.g. Runtime error 3075 - Syntax error : Click image for larger version. 

Name:	runtimeerror3075.jpg 
Views:	8 
Size:	28.5 KB 
ID:	26305

    I'm new to VBA (and all code to be honest), so if there's a simple fix I'm missing, please don't worry about insulting my intelligence!

    Any help is welcome (but please avoid telling me to use macros and queries)

    Thanks in advance!
    Attached Thumbnails Attached Thumbnails runtimeerror3075.jpg  

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You're missing the "*" in the front: OR [ProjectName] like'*" & Me.txtKeywords & "*'

  3. #3
    gbolsover is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Nov 2016
    Posts
    2
    Quote Originally Posted by aytee111 View Post
    You're missing the "*" in the front: OR [ProjectName] like'*" & Me.txtKeywords & "*'
    You're a hero! That has been racking my brain for hours.

    Thank you!

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

Similar Threads

  1. Replies: 4
    Last Post: 08-07-2015, 07:49 AM
  2. Selecting field based on effective date
    By Luffk73 in forum Access
    Replies: 1
    Last Post: 03-30-2015, 12:40 PM
  3. Search on text fields - Wildcard?
    By Harley Guy in forum Queries
    Replies: 3
    Last Post: 08-13-2013, 11:07 AM
  4. Replies: 1
    Last Post: 08-04-2011, 04:17 PM
  5. OLE and Text Field with MS Word
    By WBlohm in forum Programming
    Replies: 0
    Last Post: 09-09-2010, 12:56 PM

Tags for this Thread

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