Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Having an issue with a report...

    Hello,

    I have a report, in which is a field (txtInvoice) that may or may not need to be flagged based on a query (qry_FlagInvoice2). Basically, if that invoice # shows up in the query I want two icons (Flag1 and Flag2) to become visible. All of this is in a group header.

    This works great if I only have one invoice number, but if I selected several from the list, the flag visibibility becomes all or nothing, for every invoice #.

    How can I get the flag icons to appear only next to the invoices that are in the query, and not next to the ones that aren't?


    Here is my code:



    Code:
    Private Sub Report_Load()
    
    On Error GoTo err_handling
    
    If Me.txtInvoice = DLookup("InvoiceNumber", "qry_FlagInvoice2") Then
    Me.Flag1.Visible = True
    Me.Flag2.Visible = True
    Else
    Me.Flag1.Visible = False
    Me.Flag2.Visible = False
    End If
    
    err_handling_resume:
    Exit Sub
    
    err_handling:
    MsgBox (Err.Number & Err.Description)
    GoTo err_handling_resume
    
    End Sub

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    That code should be in the format event of the section containing the controls, not the load event. In your case, that sounds like the group header.
    Paul

  3. #3
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by pbaldy View Post
    That code should be in the format event of the section containing the controls, not the load event. In your case, that sounds like the group header.
    Perfect, I knew I was missing something. Thank you!!

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    No problemo!
    Paul

  5. #5
    Join Date
    Oct 2009
    Posts
    204
    Ok last night I thought that worked well, until I came upon an issue this morning.

    It works if I only have one item flagged. However, if there are multiple, it only works with the first one in the list. How can I get this to work for all items?

  6. #6
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Do you have the same code there (with the Else clause)? Can you post a sample db?
    Paul

  7. #7
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by pbaldy View Post
    Do you have the same code there (with the Else clause)? Can you post a sample db?
    Yes it is the same code. Here is the db. The report in question is "rpt_PeopleNeeded." It opens from "frm_PeopleNeeded."
    Attached Files Attached Files

  8. #8
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Ah; what view are you using? The format event will only fire in Print or Preview modes, not the new Report view (which acts more like a form). Try opening in Preview mode.
    Paul

  9. #9
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by pbaldy View Post
    Ah; what view are you using? The format event will only fire in Print or Preview modes, not the new Report view (which acts more like a form). Try opening in Preview mode.
    My code from clicking the button opens the report in print preview.

    Code:
    DoCmd.OpenReport "rpt_PeopleNeeded", acViewPreview, , strWhere

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    I'm sorry, I misunderstood the problem. Try this test:

    If DCount("*", "qry_FlagInvoice2", "InvoiceNumber='" & Me.txtInvoice & "'") > 0 Then
    Paul

  11. #11
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by pbaldy View Post
    I'm sorry, I misunderstood the problem. Try this test:

    If DCount("*", "qry_FlagInvoice2", "InvoiceNumber='" & Me.txtInvoice & "'") > 0 Then
    Score!!

    You, sir, are a wizard. Thanks much!

  12. #12
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Glad we got it sorted out for you.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •