Need help with the basics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn29316
    New Member
    • Feb 2007
    • 33

    Need help with the basics

    I feel foolish for posting this question but I don't get to program often enough over the past few years to remember how to do much of anything. What I'm trying to do is to use the info in a field to run a query, which is the backbone of a report. The input table would be something like:

    Date Work Order
    11/1/07 123456
    11/2/07 987654

    I want to take the Work Order number to open a report multiple times to print info related to each Work Order. I've written the report and started the module below:

    Function DoIt()
    Dim WoNum As String
    Dim k As String
    Set rs = CurrentDb().Ope nRecordset("WOs in Date Range") ' this is the table above

    varValues = rs.GetRows(999)
    rs.Close

    intFieldCount = UBound(varValue s, 1)
    intRowCount = UBound(varValue s, 2)

    For j = 0 To intRowCount
    i = 0
    k = varValues(i, j)
    Debug.Print k

    I'm struggling to figure out how to use the value I just put in k as the criteria in the query behind the report I'm trying to print. There's probably a better way but what I think I want to do is to open the report using the first Work Order value, print it, close it, then open the same report again using the second Work Order, etc.

    I'd appreciate any help I can get on this. I've wasted a couple of hours so far on this simple task.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Originally posted by Shawn29316
    I feel foolish for posting this question but I don't get to program often enough over the past few years to remember how to do much of anything. What I'm trying to do is to use the info in a field to run a query, which is the backbone of a report. The input table would be something like:

    Date Work Order
    11/1/07 123456
    11/2/07 987654

    I want to take the Work Order number to open a report multiple times to print info related to each Work Order. I've written the report and started the module below:

    Function DoIt()
    Dim WoNum As String
    Dim k As String
    Set rs = CurrentDb().Ope nRecordset("WOs in Date Range") ' this is the table above

    varValues = rs.GetRows(999)
    rs.Close

    intFieldCount = UBound(varValue s, 1)
    intRowCount = UBound(varValue s, 2)

    For j = 0 To intRowCount
    i = 0
    k = varValues(i, j)
    Debug.Print k

    I'm struggling to figure out how to use the value I just put in k as the criteria in the query behind the report I'm trying to print. There's probably a better way but what I think I want to do is to open the report using the first Work Order value, print it, close it, then open the same report again using the second Work Order, etc.

    I'd appreciate any help I can get on this. I've wasted a couple of hours so far on this simple task.
    A bit hard to grasp what repetitive printing needs to be done per WO.
    Looked like you want to print WO's with their details for a certain date-range.
    This is done by defining the report for all dates and to filter the report when activated by passing the filter needed.

    If that's not your problem, then please elaborate on what processing per WO is needed.

    Nic;o)

    Comment

    • Shawn29316
      New Member
      • Feb 2007
      • 33

      #3
      Originally posted by nico5038
      A bit hard to grasp what repetitive printing needs to be done per WO.
      Looked like you want to print WO's with their details for a certain date-range.
      This is done by defining the report for all dates and to filter the report when activated by passing the filter needed.

      If that's not your problem, then please elaborate on what processing per WO is needed.

      Nic;o)
      Nic,o

      Thanks for your reply!

      Your explanation of what I'm trying to do is right. I've had to break it down into 2 pieces because that's the only way my brain could process it. First I used a form to allow the user to enter the date range. When OK is clicked, it runs a query based on the date range and creates a table of the WOs that are within that range. Those values are what I'm putting in k above. I just can't get from that point to the criteria for the query behind the report.

      It sounds like your solution above would take out the creation of the table and the need for the module. Most of what I've done in the past has been writing SQL queries so I need to study a little and see if I can figure out how to apply "a filter to a report".

      I also may need to revisit why I enjoy working in ACCESS so much. I may be a little sick! : )

      Again, thanks!
      Shawn

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        These criteria (like those for a report) can be passed as the WHERE clause in the DoCmd like:
        [code=vb]
        DoCmd.OpenRepor t "reportname ", acViewPreview, , "WHERE condition"
        [/code]
        The WHERE condition looks e.g. like "StartDate between #" & Me.Startt & "# and #" & Me.End & "#"

        Nic;o)

        Comment

        Working...