nuff_said
01-24-2007, 01:36 PM
We have a simple Access application for customer data that has one primary form with all the demographic info. Users have been clicking on the new record button and then using a Print button on the form that does a "DoCmd.PrintOut acSelection" to print out a blank form for the customer to fill out. I am now adding some functions to this application to make it work like an application and I want to automate this function on a single button. I do not have the luxury of time to create a report, so please don't tell me to make a report. I just want a single button on a menu to print this "blank form". How to do this??
Moniker
01-28-2007, 03:45 PM
Make a copy of the table you are currently using as the recordsource for the report. Delete all the records out of it and name something like "t_YourTableName_BLANK". You're doing this to keep the same structure and field names that the report already has on it. If you're using a query, temporarily change the type to a Make Table query, and have it make a table called t_YourTableName_BLANK. Then go in that table and delete all the records. (Don't forget to change the query type back to whatever it currently is.)
In the "Print Blank Form" button's OnClick event, change the report's RecordSource from t_YourTableName to t_YourTableName_BLANK, open and print the form, and then change the RecordSource back to t_YourTableName before closing it.
I don't remember if you can change a report's RecordSource without opening it, so if that becomes a problem, make a global variable at the top of any module (not in any function or sub), something like this:
Global PrintBlankForm As Boolean
In the "Print Blank Form" button's OnClick event, do something like this:
PrintBlankForm = True
<code to open, print, and close the report goes here>
PrintBlankForm = False
In the report's OnOpen event, put simple code to change the RecordSource, like this:
If PrintBlankForm Then
Me.RecordSource = t_YourTableName_BLANK
Else
Me.RecordSource = t_YourTableName
End If
nuff_said
01-29-2007, 07:37 AM
Moniker -
I appreciate the info, but I am not printing a report. The current button on the form simply has the command "DoCmd.PrintOut acSelection". The users click on the navigation button to add a new record, then click the button to print on the form to print a "blank" form. There is no report that is being printed. How do I perform this function from a single menu option from the Switchboard?
Moniker
02-01-2007, 10:02 AM
CurRecord = Me.CurrentRecord
DoCmd.GoToRecord acDataForm,Me.Name,acNewRec
DoCmd.PrintOut acSelection
DoCmd.GoToRecord acDataForm,Me.Name, acGoTo, CurRecord
That will get the record the user is currently on and store it in the CurRecord variable. It will then navigate to a new record, print out the blank form, and return to the record the user was last on.
Colefr
07-14-2008, 08:59 AM
I'm trying to do exactly what "nuff_said" is. I tried the suggest code but I continue to hit this road block: if the form is blank, Access prints a blank page. I have no trouble printing a form if the fields are populated.