Control Source for text box on report to display the field name

L

livin''''life

I have a database that tracks employees and the dates that they have
completed some training. Example:

SSN Last First MI Class1 Class2 Class3 Class 4 etc...

I have created a form that allows me to print a report of all employees that
have completed a class. Using a dropdown box it builds queries on the fly
and sends the info to a report.

What I would like to do is place a button on the form that will print all of
these reports. The direction that I am heading is that when the user clicks
the button the following happens:
1. Build a query for all who completed Class1 (always named qry_ClassComplete)
2. Sends it to a report (always named rpt_ClassComplete)
3. Report Prints
4. Deletes the query
5. Build a query for all who completed Class2
etc...

What I would like to do is add a text box to the report that displays the
name of the class at the top. Ex(List for Class: Class1) where the class1
changes on each report. Not sure if this is possible so any help is
appreciated.

Also, if you know a better way to do this I am open to that too. Thank you
all for the time you take to answer our questions.
 
L

livin''''life

Here is the code I am using to help in case I did not explain it as well as
it could have been done.

'Class1

dbs.QueryDefs.Delete ("qry_ClassComplete")
strSql = "SELECT [tbl_ClassDates].[Social_Security_Number],
[tbl_ClassDates].[Last_Name], [tbl_ClassDates].[First_Name],
[tbl_ClassDates].MI
FROM [tbl_ClassDates]
WHERE ((([tbl_ClassDates].Class1)
=[Forms]![frm_PrintClassList]![txt_ClassDate1])) AND
((([tbl_ClassDates].[Class1])
<=[Forms]![frm_PrintClassList]![txt_ClassDate2]))
GROUP BY [tbl_ClassDates].[Social_Security_Number],
[tbl_ClassDates].[Last_Name], [tbl_ClassDates].[First_Name],
[tbl_ClassDates].MI
ORDER BY [Last_Name], [First_Name];"
Set qdf = dbs.CreateQueryDef("qry_ClassComplete", strSql)

Reports!rpt_ClassComplete!txt_ClassName = "Class1" (for some reason this is
not displaying the information)
DoCmd.OpenReport stDocName, acViewNormal
DoCmd.DeleteObject acQuery, "qry_ClassComplete"

'Class2

Same as above but for Class2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top