Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    OK - do you want to upload a stripped down copy of your database with the form, report & anything else needed to check this out for you.
    If so, I'll have a look later this evening
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  2. #17
    frons's Avatar
    frons is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Apr 2015
    Location
    Belgium
    Posts
    17
    Here it is, hope it can be of any help, and thank you for all your time, you've already helped me a lot!
    Attached Files Attached Files

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Your comboboxes are named cmbTurno and cmbTema but the code uses cboTurno and cboTema. (I prefer cbx prefix.) Fix names or fix code.

    Select [Event Procedure] in the combobox AfterUpdate property.


    The variables need to be string, not integer, type.

    Public strTurno As String
    Public strTema As String


    Problem with this method is Format events only trigger for PrintPreview or direct to printer, not ReportView. Alternatively, the code will work in report Load event for any view.

    An alternative to any event code is a function called by a textbox (textbox acts as 'label').

    Code:
    Private Function SetLabel() As String
        SetLabel = "Fanculo"
        If Nz(strTema, "") <> "" And Nz(strTurno, "") <> "" Then
            'Sono stati selezionati sia un turno che un tema
            SetLabel = "Tema " & strTema & "; Turno " & strTurno & ""
        ElseIf Nz(strTema, "") <> "" Then
            'Un tema è stato selezionato
            SetLabel = "Tema " & strTema & ""
        ElseIf Nz(strTurno, "") <> "" Then
            'Un turno è stato selezionato
            SetLabel = "Turno " & strTurno & ""
        Else
            'Nessuna selezione: sono stati selezionati tutti i record
            SetLabel = "Tutti gli studenti"
        End If
    End Function
    Textbox ControlSource: =SetLabel()


    Also, variables lose their values when code execution is interrupted. Can be frustrating when debugging and code is dependent on global or public variables. Could make the variables local in the report code and set them by reference to the form controls.

    Or use TempVars which don't lose value (I've never used them).
    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. #19
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    All done.
    The errors were caused by copying my code without adapting for your database
    a) The 2 public variables need to be String not Integer
    b) The combo boxes are called cmbTema (not cboTema) & cmbTurno (not cboTurno) so the code wasn't firing

    The report now shows the filter info label correctly.

    I've taken the liberty of removing the layout guides as they were driving me nuts
    I've also added 2 small buttons to clear each combo on the form

    Hope you're happy with this

    EDIT: Just spotted that whilst I was looking at your db, June found the same issues
    I had also changed the code to open the report in print preview using a procedure & got rid of the embedded macro (as I hate them!)
    Attached Files Attached Files
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #20
    frons's Avatar
    frons is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Apr 2015
    Location
    Belgium
    Posts
    17
    Quote Originally Posted by June7 View Post
    Public strTurno As String
    Public strTema As String
    I totally missed that, gosh!
    Thank you

  6. #21
    frons's Avatar
    frons is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Apr 2015
    Location
    Belgium
    Posts
    17
    Quote Originally Posted by ridders52 View Post
    Hope you're happy with this
    More than happy, looks like Christmas morning !
    Now I need to scope everything bit by bit to fully understand what my mistakes were.
    Thank you

  7. #22
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Excellent. Happy early Xmas.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-22-2016, 08:42 AM
  2. Replies: 11
    Last Post: 08-06-2014, 09:47 AM
  3. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  4. Combo Boxes Query Criteria help
    By noaccessguru in forum Queries
    Replies: 2
    Last Post: 04-30-2012, 08:09 PM
  5. Running a query based on 2 combo boxes.
    By blessoni in forum Queries
    Replies: 4
    Last Post: 12-12-2010, 02:09 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