473,378 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Printing one Record

I am triyng to print the current record using this but when i hit the button another record was printed.
Expand|Select|Wrap|Line Numbers
  1. Private Sub PRINT_Click()
  2. On Error GoTo Err_PRINT_Click
  3.  
  4. Dim MyForm As Form
  5. Dim record_num As Long
  6.  
  7. stDocName = "PerformancePay"
  8. Set MyForm = Screen.ActiveForm
  9. DoCmd.SelectObject acForm, stDocName, True
  10. record_num = MyForm.CurrentRecord
  11. DoCmd.PrintOut acPages, record_num, record_num
  12.  
  13.  
  14. Exit_PRINT_Click:
  15. Exit Sub
  16.  
  17. Err_PRINT_Click:
  18. MsgBox Err.Description
  19. Resume Exit_PRINT_Click
  20.  
  21. End Sub
Sep 3 '08 #1
8 2886
Stewart Ross
2,545 Expert Mod 2GB
Hi. There is no obvious fault with what you have, although if your command button is on the same form you don't need to use screen.activeform - you can just refer to me.currentrecord instead.

Try the following and see if it still gives you the wrong page:

DoCmd.PrintOut acSelection

(you don't need to specify the page for this option, so comment out or remove lines 8-10 above).

-Stewart
Sep 3 '08 #2
Now i can print the current record but now is printing 3 extra pages one with the command buttons and the other two with the color background
Sep 4 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi. DoCmd.Printout is intended to print the form as it appears on screen - complete with buttons and so on. The acPages qualifier you used originally restricts printing to specific pages of the form, but you indicated that it was printing the wrong record (it works fine for me on my test system).

You could revert to your original code, substituting me.currentrecord for your myform reference to screen.activeform and leaving out lines 8-10 to see what happens this time, as below:

record_num = me.currentrecord
DoCmd.PrintOut acPages, record_num, record_num


-Stewart
Sep 4 '08 #4
Hi. DoCmd.Printout is intended to print the form as it appears on screen - complete with buttons and so on. The acPages qualifier you used originally restricts printing to specific pages of the form, but you indicated that it was printing the wrong record (it works fine for me on my test system).

You could revert to your original code, substituting me.currentrecord for your myform reference to screen.activeform and leaving out lines 8-10 to see what happens this time, as below:

record_num = me.currentrecord
DoCmd.PrintOut acPages, record_num, record_num


-Stewart
You say 8 thru 10 0r 8 and 10
Sep 4 '08 #5
Stewart Ross
2,545 Expert Mod 2GB
8 through 10 - no need at all to select the form specifically, or set myform to screen.activeform, or set rec_num to the value of myform.currentrecord.

-Stewart
Sep 4 '08 #6
This what i have so far and is printing one page with out buttons but the wrong record.
Expand|Select|Wrap|Line Numbers
  1. Private Sub PRINT_Click()
  2. On Error GoTo Err_PRINT_Click
  3.  
  4. Dim MyForm As Form
  5. Dim record_num As Long
  6.  
  7. stDocName = "PerformancePay"
  8. record_num = Me.CurrentRecord
  9. DoCmd.PrintOut acPages, record_num, record_num
  10.  
  11.  
  12. Exit_PRINT_Click:
  13. Exit Sub
  14.  
  15. Err_PRINT_Click:
  16. MsgBox Err.Description
  17. Resume Exit_PRINT_Click
  18.  
  19. End Sub
Sep 4 '08 #7
Please i still with the same problem
Sep 4 '08 #8
Stewart Ross
2,545 Expert Mod 2GB
Sorry, I can suggest no more as this appears to be something specific to your particular form in your particular circumstances.

You could devise a proper report for your users then print that using DoCmd.OpenReport, supplying a WHERE clause to filter the records and restrict printing to just the one record. That is what I do myself; I do not use the form-based PrintOut at all. I must leave further investigation of that kind of option to you however.

-Stewart
Sep 4 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Baker | last post by:
Hi: I have a form, which contains a sub form (Employee main record and payment record). It all shows up fine in a screen view, but when I come to print it I find that I cannot get the sub form...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
1
by: Frank.Sebesta | last post by:
I have a employees database with a picture that shows on a form with employee information. Similar to the Northwinds sample database. When I print the record, my output is only the data and does...
5
by: John | last post by:
Hi If I have a form open, what is the code that is equivalent to using the File->Print menu with select record(s) option to print the form with the currently displayed record values? Thanks ...
5
by: bobh | last post by:
Hi All, A clients database (built by another and not very well but, its what I have to work with) has bound forms that display customer information and when printed is three pages long. The...
7
by: Burhan | last post by:
Hello Group: I am in the planning stages of an application that will be accessed over the web, and one of the ideas is to print a barcode that is generated when the user creates a record. The...
1
by: Casey Skousen | last post by:
I want to be able to batch print all records in a header table that have not yet been printed. This should be simple, but due to the format of the report, I cannot just print all records (the...
0
by: nikhilgargi | last post by:
Requirement: I need to provide printing capability in a C# desktop application that I am developing The documents that need to be printed can be in Rich Text Format (RTF) or HTML. Custom...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
it0ny
by: it0ny | last post by:
Hi guys, thanks I am fairly new to this forum so I hope I chose the right place to post this question. I try to make my program printout a deposit's report. I created a class to store the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.