lillyellen
Aug 17 2005, 06:02 AM
I need to be able to record the date a report (cheque requisition) is printed.
The report is opened via a button on the main Orders form.
Please help
ScottGem
Aug 17 2005, 06:05 AM
if you use the Wizard to design your report, it automatically inserts a date/time stamp.
lillyellen
Aug 17 2005, 07:06 AM
Thanks for replying so soon.
I have not tried your suggestion yet as I think that the date you refer to show just the current date that the report is opened, and changes each different day you open the report.
I need to record the date the report is actually printed, and be able to refer back to see if a particular cheque requisition was raised, so that it isn't duplicated, perhaps having the date and customer ID recorded in a "Cheque Printed" table.
I think this needs to be written in the VBA code, and I am a complete novice with VBA!
Larry Larsen
Aug 17 2005, 08:47 AM
Hi
You can write both date & time into a table that holds the data.
This would be behind the click event of the button that prints the report.
eg:
CODE
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("YourReportTablenameHere")
rec.AddNew
rec!PrintDate = Now() 'Both date and time stamp
rec.Update
rec.Close
Set rst = Nothing
ScottGem
Aug 17 2005, 11:19 AM
Larry gave you one way, but a lot depends on how you have locked down your database. what happens if a user previews the report then prints it from the menu or tool bar? If you want to ensure that you have the actual print date/time stamp recorded you need to disable the Access menus and tool bars. You can only permit printing through menus or buttons that you create. The actual recording is easy, its making sure that users only print through the tools you provide them.
I think if you goal is to make sure that a cheque isn't printed twice, you would be better off marking the checque record as being printed. If someone tries to print it again, you can flag it that way. But that still leaves you with the question of how to make sure the cheque was printed.
lillyellen
Aug 17 2005, 08:25 PM
Hi,
Thanks for replying.
I've tried putting the code into the On click event of a button created to print the Cheque requisition, but Access doesn't like it. It's highlighting the line "Dim bd As DAO.Database" and a pop-up box say that "User-Defined type not defined".
I know very little about VBA, and a lot of what's shown in the code makes no sense to me.
I was trying to get the button to print the report and at the same time record the date/time in a new table with a date field and Customer ID field, making a start with your code and the buttons automatically created code. So far the code looks like this, but doesn't yet deal with the customer ID:-
Private Sub PrntSetChq_Click()
On Error GoTo Err_PrntSetChq_Click
Dim stDocName As String
stDocName = "RptSetChq"
DoCmd.OpenReport stDocName, acNormal
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblChqPrntdDte")
rec.AddNew
rec!PrintDate = Now() 'Both date and time stamp
rec.Update
rec.Close
Set rst = Nothing
Exit_PrntSetChq_Click:
Exit Sub
Err_PrntSetChq_Click:
MsgBox Err.Description
Resume Exit_PrntSetChq_Click
End Sub
Larry Larsen
Aug 17 2005, 08:30 PM
Hi
Make sure you have DAO 3.6 ticked and moved up the list in your reference library.
Then recompile..
lillyellen
Aug 17 2005, 08:53 PM
Larry,
I'm really sorry, I've looked in Help, and tools menu to find this list and the reference library. I've no idea where they are.
I have very little knowledge of the working of Access, having just used wizards and the toolbox before. This project is my first involving VBA code.
Please advise!
Regards
Martin
Larry Larsen
Aug 17 2005, 09:04 PM
Hi
Ok..
Open a form in design view..
Click the multi-colour icon called "Code"
Then select Tools > References..
Here you will a small dialog window showing you a list of selected libraries.
I have attached a small picture of my current db.
All you need to do is scroll down and select DAO3.6..
Don't for get to compile your code after updating the list.
HTH's
lillyellen
Aug 17 2005, 09:06 PM
Found it!
I was looking in the tools for the form not the code.
Sorry.
lillyellen
Aug 17 2005, 09:41 PM
Larry,
The button now prints the cheque requisition, but where is the date/time recorded and how would I have this date entered in my table for future reference.
Thank you for bearing with me on this.
Regards
Martin
Larry Larsen
Aug 17 2005, 10:33 PM
Hi Martin
If I look at your code above:
CODE
Dim stDocName As String
stDocName = "RptSetChq"
DoCmd.OpenReport stDocName, acNormal
Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblChqPrntdDte")
rec.AddNew
rec!PrintDate = Now() 'Both date and time stamp
rec.Update
rec.Close
Set rst = Nothing
The click event sets the report name and initiates a print, this is followed by some code to place the date&time in a field called PrintDate in a table you called "tblChqPrntdDte"
The record should be in the table.
lillyellen
Aug 28 2005, 02:12 PM
Larry,
Sorry I haven't come back to you sooner, but the project had to be put on the back-burner faor the last week or so.
I've now got it going very well with your help.
Thanks for all your help and time, I appreciate it very much.
All the best,
Martin
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.