Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Dec 2002
    Posts
    15

    Unanswered: Printing certain reports

    Hi,

    Thanks to m.timoney i solved my last problem, now i have another problem popping up;

    I have a list of persons in a table linked to a combobox, when i select this person in this box and push the buytton next to it. It prints out 15 reports wich all contain data conserning this person.
    Now it is the case that i made this button just print out all the reports and look up the ID that goes with it.

    How it is now is that for example JOHN has data in all 15 tables, so if i select JOHN in my combobox and hit the print button it prints out all 15 reports (linked to query's by using [forms]![form_name]![combobox_name])
    What i want to achieve now is for example MIKE has data in 9 of the 15 reports (linked to query's by using [forms]![form_name]![combobox_name])
    so what i want is when i select MIKE in the combobox and then i hit the print button it prints these 9 reports and not all 15.

    So basically what i need is a command that checks if the person is present in the query wich contains the data for the report.


    Thanks,


    Capp

  2. #2
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    i'm not sure i understand what your trying to do

    the 'like [forms]![form_name]![combobox_name]' will select all record that match the combo box

    so if the combo box says mike the query will show all records that mike is on and if a report is based on that query it will contain all the record with mike in them and only those
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  3. #3
    Join Date
    Dec 2002
    Posts
    15

    yes

    Yes, but if there is no record it will print the empty layout of the report, so this is a wasted piece of paper

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    so what you want to do is cancel the print if the page is empty?
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Dec 2002
    Posts
    15
    Yes

  6. #6
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    right i'll look into it

    speaking of which
    a large hole has appeared in the yorkshire moors the police are currently looking into it,

    ***he duck the various household appilances thrown at him
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  7. #7
    Join Date
    Dec 2002
    Posts
    15
    I don't get it?

  8. #8
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    sorry that awful joke depends on the fact that the sentence has a double meaning, the police are looking into it
    1. the police are investigating the hole
    2. the police are physicaly looking into the hole
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  9. #9
    Join Date
    Dec 2002
    Posts
    15

    o

    Can't i use something like "IF value is 0 DoCmd.DoNotPrint" or something?
    My friend is telling me to look in the visual basic studio but i aint getting any smarter by doing that

  10. #10
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    sorry with other post i forgot abou this one
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  11. #11
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    try this

    Code:
        Dim db As DAO.Database, rs As DAO.Recordset
        Set db = CurrentDb
        Set rs = OpenRecordset("<queryname>", dbOpenSnapshot)
        If rs.RecordCount <> 0 Then
            <print command>
        End If
    this code needs to be added to teh print button
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  12. #12
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you could also try a domain aggregate function:

    if DCount("[aFieldNameInYourQuery]", "nameOfYourQuery") then
    ...do your report
    endif


    izy

  13. #13
    Join Date
    Dec 2002
    Posts
    15
    I added the code like this:

    Private Sub yo_Click()
    On Error GoTo Err_yo_Click

    Dim db As DAO.Database, rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = OpenRecordset("selectie eftel", dbOpenSnapshot)
    If rs.RecordCount <> 0 Then

    Dim stDocName As String

    stDocName = "Selectie eftel"
    DoCmd.OpenReport stDocName, acNormal


    End If



    Exit_yo_Click:
    Exit Sub

    Err_yo_Click:
    MsgBox Err.Description
    Resume Exit_yo_Click

    End Sub


    But it gives me a compile error, wich makes the private sub part yellow and highlights the db As DAO.databse part

    I am going to try the other solution now, just toughtu might wanna know

  14. #14
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    oooooops

    you could also try a domain aggregate function:

    if DCount("[aFieldNameInYourQuery]", "nameOfYourQuery") > 0 then
    ...do your report
    endif


    izy

  15. #15
    Join Date
    Dec 2002
    Posts
    15
    This seems to be working!

    THANKS

Posting Permissions

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