Results 1 to 4 of 4
  1. #1
    Farnarkle is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    2

    Search as you type

    Hi everyone,


    I have this code in a search as you type combo box, which I copied from here:

    http://blogs.office.com/2012/05/03/u...h-as-you-type/

    It works fine on the above site, but I get errors on my system Access 2013 Windows 8.
    THe website punctuation is different in that the apostrophes face left and all the double quotes are the same..... I Cannot duplicate them


    Private Sub cboFilter_Change()


    ' If the combo box is cleared, clear the form filter.
    If Nz(Me.cboFilter.Text) = "" Then
    Me.Form.Filter = ""
    Me.FilterOn = False

    'If a combo box item is selected, filter for an exact match.
    'Use the ListIndex property to check if the value is an item in the list.
    ElseIf Me.cboFilter.ListIndex <> -1 Then
    ' THE FOLLOWING LINE RETURNS A SYNTAX ERROR
    Me.Form.Filter = "[Company] = '" & Replace(Me.cboFilter.Text, "'", """ & "'"
    Me.FilterOn = True

    ' If a partial value is typed, filter for a partial company name match.
    Else
    ' AS DOES THIS ONE
    Me.Form.Filter = “[Company] Like '*" & Replace(Me.cboFilter.Text, "'", """) & "*'"
    Me.FilterOn = True


    End If

    'Move the cursor to the end of the combo box.
    Me.cboFilter.SetFocus
    Me.cboFilter.SelStart = Len(Me.cboFilter.Text)




    End Sub


    any help appreciated...

    Farnarkle

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Personally, I use the one found here. http://allenbrowne.com/appfindasutype.html

    HTH

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Believe me, you don't want those slanted apostrophe and quote marks - VBA won't like them. I think that site has error. The Replace function is to replace a single apostrophe with 2 apostrophes, not a quote mark. This is so an apostrophe in the text will be read as a literal apostrophe, not as a delimiter character. So a value like: "McDonald's Farm" won't error in the search criteria.

    Your code is missing a paren in the first Replace().

    Me.Form.Filter = "[Company] = '" & Replace(Me.cboFilter.Text, "'", "''") & "'"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Farnarkle is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    2
    To June7 ... thanks for that, it was a bit easy to miss on a laptop screen. I got the code to validate but the whole thing didnt work for me anyway

    Burrina, thanks for the link. I can adapt that for my needs. I am coding an IMDB database ( just for something to do) using this model:
    http://www.databaseanswers.org/data_models/imdb/

    I have the bare framework working ok and now fleshing it out.

    I needed a popup to select actors and the like from the people list and add new ones (NotIn List) to existing table and/or into a new movie, hence the post.

    Farnarkle

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

Similar Threads

  1. Type mismatch from search field
    By gemadan96 in forum Programming
    Replies: 3
    Last Post: 01-09-2014, 09:29 AM
  2. Search as you type Row Source Alteration
    By michael.legge@rbc.com in forum Access
    Replies: 1
    Last Post: 07-03-2013, 08:45 AM
  3. problems with search as you type forms
    By sk88 in forum Access
    Replies: 1
    Last Post: 06-27-2012, 02:01 PM
  4. Search as you type
    By CaptainKen in forum Programming
    Replies: 19
    Last Post: 04-25-2012, 12:55 PM
  5. search as you type in combo box
    By pratim09 in forum Forms
    Replies: 3
    Last Post: 08-05-2011, 07:46 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