Converting data from a column into vba script to print repots

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RyanRimmel
    New Member
    • Dec 2010
    • 1

    #1

    Converting data from a column into vba script to print repots

    Hello,

    My issue is that I have a form and report that are required to be printed out daily and each sheet must presently be selected by the individual record to have the forms print because they use a SQL SELECT TOP 40 to generate the data set based on the employee's number.

    That SQL statement is :
    strSQL = "SELECT TOP 40 [Job Table].[KMA Job #], [Job Table].[Job Completion Notes], [Job Table].[Asg Unit], Right([kma job #],1) AS Event, Left([kma job #],2) AS Stuff, Left([Job Description],3) AS estTrk FROM [Job Table] INNER JOIN Customer ON [Job Table].Customer = Customer.Custom er WHERE (((Customer.Typ e) = 'Residential')) GROUP BY [Job Table].[KMA Job #], [Job Table].[Asg Unit], Right([kma job #],1), Left([kma job #],2), Left([Job Description],3), [Job Table].[Job Completion Notes] HAVING ((([Job Table].[Asg Unit])=" & stData & ") AND ((Left([Job Description],3))='est')) ORDER BY [Job Table].[KMA Job #] DESC;"

    where stData is equal to the unit number of the employee which is selected from a combobox on the form. The selects the last 40 jobs for an employee.

    The query (qryTechNumber) that I want to pull the data from looks like:

    Unit
    20
    25
    28
    32

    My employer wants to push a single button and have all of the forms/reports print out in sequence. The employee's change frequently so I need to build the form in such a way that I don't have to modify the underlying code to make it work.

    What I need is a method that will take the data from that query at place it into the stData field and print the form. I can handle the SQL and the looping equation, but what I cannot figure out is how to get the data from the query and place it into a method that I can place into the stData field.

    Because I am using "SELECT TOP" in my SQL statement I cannot simply make a big master report with all the employees and I need to generate it on a per employee basis.
    Last edited by RyanRimmel; Dec 22 '10, 03:06 PM. Reason: Adjusting question per feedback.
  • orangeCat
    New Member
    • Dec 2007
    • 83

    #2
    TOP 40 what?
    You really print out Forms, or do you print out Reports?
    You say you use SQL to generate the Form? I think you use SQL to select the data required to satisfy the request, then use a Form or Report to Format the data into the proper format.

    I think you should review the requirement; write down exactly what is needed; then start to translate that into Access queries/forms/reports etc; do some testing and even Create a separate form with a Button so whoever wants to push the button and have all the reports can do so.

    Comment

    Working...