Results 1 to 8 of 8
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Filter email field on continuous form gives error

    Private Sub txtEmailFilter_AfterUpdate()
    Me.Filter = "[SchoolEmail]= Me.txtEmailFilter"
    Me.FilterOn = True
    End Sub

    I can't seem to get this to work

    I keep getting an error

    eventually I will use nz() but for now I just need to figure out why the code above is wrong.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Don't include variables within quote marks, that results in the variable name as literal text and not the value of the variable. Reference to control on form is a variable. Concatenate variables.

    Me.Filter = "[SchoolEmail]='" & Me.txtEmailFilter & "'"
    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.

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Don't include variables within quote marks, that results in the variable name as literal text and not the value of the variable. Reference to control on form is a variable. Concatenate variables.

    Me.Filter = "[SchoolEmail]='" & Me.txtEmailFilter & "'"


    Great - filtering does work now however it has to be exact - wondering if I can place a "like" in the code so I can filter what is typed. Also how to return the form without the filter - nz() doesn't seem to work for me.

    Also I do get what you mean, rather than referencing the textbox you want me to reference the value within it. Makes sense.

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I used this for replacing the nz

    If Not IsNull(Me.txtEmailFilter) Then
    Me.Filter = "SchoolEmail Like'" & Me.txtEmailFilter & "'"
    Me.FilterOn = True
    Else
    Me.FilterOn = False
    End If

    still would like it to filter only what is typed not exact

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    Use wildcards with LIKE, otherwise might as well just be =.

    Try:

    Me.Filter = "SchoolEmail LIKE '*" & Me.txtEmailFilter & "*'"
    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.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    Use wildcards with LIKE, otherwise might as well just be =.

    Try:

    Me.Filter = "SchoolEmail LIKE '*" & Me.txtEmailFilter & "*'"
    ah - wildcard * got it. And put another on the other end to signify between wildcard?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,956
    On each end to match any characters found before and after the input. Use either or both.
    Last edited by June7; 10-11-2013 at 12:53 AM.
    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.

  8. #8
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by June7 View Post
    On each end to match any characters found before and after the input. User either or both.
    Thanking you

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

Similar Threads

  1. Replies: 3
    Last Post: 09-23-2013, 06:42 AM
  2. No Current Record error - Continuous Form
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 08-25-2012, 08:43 AM
  3. Replies: 1
    Last Post: 11-24-2011, 07:45 AM
  4. Filter a Continuous Form
    By michel_annie22 in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 07:34 AM
  5. Replies: 2
    Last Post: 04-12-2011, 08:33 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