Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2021
    Posts
    14

    Question Report follows filtres from a form - is it possible or not?

    Hello,
    I have a question about queries/form/reports.

    tblProvolone = name, surname, job
    qryProvlone from tblProvolone


    frmProvolone and rptProvolone from qryProvolone

    qryProvolone/frmProvolone/rptProvolone haven't filters, but i can filter them with combobox filters.

    example - (cboName select "Ma") i have in frmProvolone: SELECT * FROM qryProvolone WHERE [name] Like "*Ma*";
    I want have this results in rptProvolone automatically so i can print a report only what i want

  2. #2
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Yes, you can create a separate Query, using qryProvolon as Source for Report as shown above with the criteria under the [Name] Column as shown below:
    Code:
    Like "'" & Forms!frmProvolon!cboName & "'"
    On the cboName Update Event Procedure enter the Me.Refresh Statement to refresh the Query Recordset immediately after the combobox content is changed and to get the data filtered for the Report.

  3. #3
    Join Date
    Mar 2021
    Posts
    14
    I would like to make a report with all Names. Actually it's giving me just the selected record. For example i want Mario/Matteo/Emmanuela, etc. all in a report (not separated)

    Private Sub Comand_Click()
    DoCmd.OpenReport "RptProvolone" _
    , acViewNormal, , "Name='" & Name _
    & "'"
    End Sub

  4. #4
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Be aware that "Name" is a reserved word in Access and shouldn't be used as an object name.

  5. #5
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    258
    If you post an example file it may be easier to understand how to help you.

  6. #6
    Join Date
    Mar 2021
    Posts
    14
    This is the link for access file i created:

    https://1drv.ms/u/s!AjFLWnkU3pswhJM7...FMLKA?e=2dwVPJ

    I would like to filter for Job, Name or Surname (with multiple records results) and open rptProvolone with all records results in frmProvolone

  7. #7
    CarlettoFed is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    258

    Risposta

    You need to replace all the code in the Form_frmProvolone module with the following:
    Code:
    Option Compare Database
    Option Explicit
    
    Dim strFiltro As String
    
    Private Sub cboJob_AfterUpdate()
        FiltraDati
    End Sub
    
    Private Sub cboName_AfterUpdate()
        FiltraDati
    End Sub
    
    Private Sub Form_Load()
        FiltraDati
    End Sub
    
    Private Sub noFilter_Click()
        Me.cboJob = Null
        Me.cboName = Null
        FiltraDati
    End Sub
    
    Private Sub stmpProvolone_Click()
        DoCmd.OpenReport "RptProvolone", acViewPreview, , strFiltro
    End Sub
    
    Private Sub FiltraDati()
        strFiltro = ""
        If Len(Trim(Me.cboJob & "")) > 0 Then strFiltro = "[Job] Like ""*" & Me.cboJob & "*"""
        If Len(Trim(Me.cboName & "")) > 0 Then strFiltro = strFiltro & IIf(strFiltro = "", "", " AND ") & "[Name] Like ""*" & Me.cboName & "*"""
        Me.Filter = strFiltro
        If strFiltro = "" Then
            Me.FilterOn = False
        Else
            Me.FilterOn = True
        End If
        Me.stmpProvolone.Visible = Not IsNull(Me.ID)
    End Sub

  8. #8
    Join Date
    Mar 2021
    Posts
    14
    Thank you !!!

  9. #9
    DittoBird's Avatar
    DittoBird is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2015
    Location
    Newfoundland & Labrador, Canada
    Posts
    59
    Another possibility is to set up qryProvolone with criteria like this (repeat for name - see note following, and surname if you add a combo box for it). It is pretty much what @apr pillai has mentioned, except I added nz in case any of the combo boxes are null.

    Like "*" & Nz([Forms]![frmProvolone].[cboJob],"") & "*"

    I would then change your afterupdate events to:

    Code:
    Private Sub cboJob_AfterUpdate()
        Me.Requery
    End Sub
    
    Private Sub cboName_AfterUpdate()
        Me.Requery
    End Sub
    You may also want to add another combo box for surname.

    NOTE YOU MUST change "name" in your tale to something else as @ssanfu has mentioned above.
    --
    Tim
    Last edited by DittoBird; 03-18-2021 at 02:10 PM. Reason: I am not allowed to add images for some stupid reason JFC

  10. #10
    Join Date
    Mar 2021
    Posts
    14
    This is the code:

    Option Compare Database
    Option Explicit


    Dim strFiltro As String


    Private Sub cboAggiornamentoPratica_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub cboAvvocato_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub cboIncarico_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub cboPaziente_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub cboProcuratore_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub cboStatoPratica_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub cboConsulente_AfterUpdate()
    FiltraDati
    End Sub


    Private Sub NoFilter_Click()
    Me.cboAggiornamentoPratica = Null
    Me.cboAvvocato = Null
    Me.cboIncarico = Null
    Me.cboPaziente = Null
    Me.cboProcuratore = Null
    Me.cboStatoPratica = Null
    Me.cboConsulente = Null
    FiltraDati
    End Sub


    Private Sub FiltraDati()
    strFiltro = ""
    If Len(Trim(Me.cboAggiornamentoPratica & "")) > 0 Then strFiltro = "[AggiornamentoStato] Like ""*" & Me.cboAggiornamentoPratica & "*"""
    If Len(Trim(Me.cboAvvocato & "")) > 0 Then strFiltro = "[Avvocato] Like ""*" & Me.cboAvvocato & "*"""
    If Len(Trim(Me.cboIncarico & "")) > 0 Then strFiltro = "[Incarico] Like ""*" & Me.cboIncarico & "*"""
    If Len(Trim(Me.cboPaziente & "")) > 0 Then strFiltro = "[Title] Like ""*" & Me.cboPaziente & "*"""
    If Len(Trim(Me.cboProcuratore & "")) > 0 Then strFiltro = "[Procuratore] Like ""*" & Me.cboProcuratore & "*"""
    If Len(Trim(Me.cboStatoPratica & "")) > 0 Then strFiltro = "[StatoPratica] Like ""*" & Me.cboStatoPratica & "*"""
    If Len(Trim(Me.cboConsulente & "")) > 0 Then strFiltro = "[Consulente/Specialista] Like ""*" & Me.cboConsulente & "*"""
    Me.Filter = strFiltro
    If strFiltro = "" Then
    Me.FilterOn = False
    Else
    Me.FilterOn = True
    End I
    Me.rptPrint.Visible = Not IsNull(Me.Title)
    End Sub


    Private Sub rptPrint_Click()
    DoCmd.OpenReport "RptPraticheElenco", acViewPreview, , strFiltro
    End Sub

    What should i change to filter more then 1. For example i want search cboConsulente = "Michael" and cboIncarico = "in corso". I would like to see all records for "Michael" "in corso"

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

Similar Threads

  1. Replies: 4
    Last Post: 12-09-2015, 09:02 AM
  2. Replies: 3
    Last Post: 10-19-2015, 11:05 PM
  3. Replies: 3
    Last Post: 03-11-2013, 05:11 PM
  4. Replies: 1
    Last Post: 06-26-2012, 08:19 PM
  5. Replies: 4
    Last Post: 12-13-2010, 05: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