Hi, I want to create a button so that i can print a form out either to a file or a printer, is this possible? the form is to be used as a invoice. i am using vb6, please help
regards
Printable View
Hi, I want to create a button so that i can print a form out either to a file or a printer, is this possible? the form is to be used as a invoice. i am using vb6, please help
regards
Welcome to VB Forums!
Will Me.PrintForm do it for you?
welcome to the forums ukmam....
if you do a search on the VB6 forum for "print" or "printing" you're sure to find a lot of resources to help you..... it's a seemingly overly-complicated thing to do in VB6.
Good Luck!
Or if you want to print it out in a different way to how the form looks then something like this:
VB Code:
Private Sub cmdPrint_Click() intResponse = MsgBox("Are you sure you want to print?", 4 + vbQuestion, "Print") 'Message box appears asking if you are sure you want to print If (intResponse = 6) Then 'If the answer is Yes then Printer.FontSize = 20 'Font size is 20 Printer.FontUnderline = True 'Font is underlined Printer.Font = "Arial" 'Font is Arial Printer.Print 'Prints a blank line Printer.Print Tab(1); "Customer Details" 'Prints Customer Details Printer.FontSize = 14 'Font size is 14 Printer.FontUnderline = False 'Font is not underlined Printer.Print 'Prints blank line Printer.Print Tab(10); lblName.Caption '10 spaces and prints the caption of the Name label Printer.Print Tab(10); lblAddress1.Caption '10 spaces and prints the caption of the 1st address line Printer.Print Tab(10); lblAddress2.Caption '10 spaces and prints the caption of the 2nd address line Printer.Print Tab(10); lblPostcode.Caption '10 spaces and prints the postcode Printer.Print Tab(10); lblPhone.Caption '10 spaces and prints the phone number Reference = lblName.Caption 'The variable 'Reference' is lblname.Caption Reference2 = lblPostcode.Caption 'The variable 'Reference2' is lblPostcode.caption Reference3 = lblPhone.Caption 'The variable, 'Reference3' is lblPhone.Caption Printer.Print 'Prints a blank line Printer.EndDoc 'Ends printing End If 'Ends If Function End Sub
You get the idea...
maybe this could help:
just an idea how you could use the datareport without a database ( if in case u dont have one)VB Code:
Private Sub cmdPrint_Click() Dim rs As New ADODB.Recordset Set rs.ActiveConnection = Nothing rs.CursorLocation = adUseClient rs.LockType = adLockOptimistic rs.CursorType = adOpenStatic rs.Fields.Append "myName", adChar, 30 rs.Fields.Append "myGender", adChar, 10 rs.Open rs.AddNew rs.Fields("myName") = Text1 rs.Fields("myGender") = Combo1 rs.Update Set dr.DataSource = rs dr.Sections(3).Controls("txtName").DataField = "myName" dr.Sections(3).Controls("txtGender").DataField = "myGEnder" dr.Show Set rs = Nothing End Sub
the data in my example came from a textbox and a combobox painted in a form... maybe you can modify it.. ;)
Hi, thanks for quick reply, i have created a software where the user can select information on one listbox(form1, which gets a menu information from the database) and it passes to the form2(form that i want to print) so when i select a item on the list box in form 1, the information is passed to form 2. for example i click on item 6, item 6 information is put into a list box in form 2. then i like to create a button so i can print form 2 out, for example like a print screen of form 2? i am using database microsoft access.
regards
Something likeVB Code:
'on Form1 Private Sub List1_Click() Form2.List1.AddItem List1.List(List1.ListIndex) Form2.Show End Sub 'on Form2 Private Sub Form_Load() Me.PrintForm End Sub
Probably. It is difficult to tell without knowing your setup. Do you have a printer installed on your machine?Quote:
Originally Posted by ukmam via PM
Also, there are three reasons why you shouldn't ask a question in a PM/Email:
1. You are restricting yourself to only one person in terms of a possible answer. If you keep your questions on the open forum, all sorts of people will view it, and someone else may have something to contribute.
2. Someone else could be having the same problem, and could benefit by what happens in your question post.
3. In days and weeks to come, someone may have the same issue, and do a forum search to see if the question has been asked before, and if so, what was the answer. If everything is confined to a PM/Email, they won't find anything.
:)
ok, in future i shall reply in the forums.
There is a printer installed however the form doesnt print out, it says it printing but then wait a couple of minutes then it says its failed, is this because of what the format is, for example does it view it as a image format? regards