Results 1 to 4 of 4
  1. #1
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92

    Question Show only some records in Form View

    Hi,

    I have a form that I would like to show only some records. Not all of them.
    The criteria will be a Yes/No field. If marked, should show, if not marked should hide.

    Here is the command I use to open the form I'm talking about:



    Code:
    Private Sub AbrirDadosdoSeguro_Click()
    On Error GoTo Err_AbrirDadosdoSeguro_Click
    
        Dim stDocName As String
        Dim strCriteria As String
    
    strCriteria = "[N do Cliente] = """ & Me.[N do Cliente] & """"
    
    DoCmd.OpenForm "Dados do Seguro", _
        WhereCondition:=strCriteria, _
        WindowMode:=acDialog, _
        OpenArgs:=(Me.[N do Cliente])
    
    
    Exit_AbrirDadosdoSeguro_Click:
        Exit Sub
    
    Err_AbrirDadosdoSeguro_Click:
        MsgBox Err.Description
        Resume Exit_AbrirDadosdoSeguro_Click
        
    End Sub
    The Yes/No field is called expired. I tried to edit the code to make it appear only if expired is marked but didn't work.

    Code:
    strCriteria = "[N do Cliente] = """ & Me.[N do Cliente] & """" and "[expired] = true"
    And what I get is Type mismatch.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    strCriteria = "[N do Cliente] = '" & Me.[N do Cliente] & "' and [expired] = True"

  3. #3
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92
    Thank you!
    As always a great help

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad we could help.

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

Similar Threads

  1. Hide records from Form View
    By Douglasrac in forum Forms
    Replies: 9
    Last Post: 05-13-2011, 11:55 AM
  2. Replies: 2
    Last Post: 11-05-2010, 04:47 AM
  3. Fields do not show in "Form View"
    By hawzmolly in forum Forms
    Replies: 4
    Last Post: 01-09-2010, 06:27 PM
  4. Replies: 0
    Last Post: 09-27-2009, 02:14 PM
  5. Replies: 9
    Last Post: 03-24-2009, 09:19 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