|
-
Apr 13th, 2006, 09:09 PM
#1
Thread Starter
Junior Member
Print button
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
-
Apr 13th, 2006, 09:28 PM
#2
Re: Print button
Welcome to VB Forums!
Will Me.PrintForm do it for you?
-
Apr 13th, 2006, 09:33 PM
#3
Fanatic Member
Re: Print button
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!
-
Apr 13th, 2006, 09:33 PM
#4
Member
Re: Print button
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...
-
Apr 14th, 2006, 04:23 AM
#5
Fanatic Member
Re: Print button
maybe this could help:
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
just an idea how you could use the datareport without a database ( if in case u dont have one)
the data in my example came from a textbox and a combobox painted in a form... maybe you can modify it..
On Error GoTo Hell
Hell:
Kill Me
Food For Thought:
- Do not judge a book... if you're not a judge!

-
Apr 14th, 2006, 05:53 AM
#6
Thread Starter
Junior Member
Re: Print button
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
-
Apr 18th, 2006, 05:55 AM
#7
Re: print button
Something like
VB 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
-
Apr 26th, 2006, 06:05 AM
#8
Re: print button
 Originally Posted by ukmam via PM
Hi, u recently gave me the me.printform to try out on my program, but i dialog appears and it says printing... but then an error pops up saying run time error "482" Printer error? is this because my printer isnt set up? thanks
Probably. It is difficult to tell without knowing your setup. Do you have a printer installed on your machine?
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.
-
Apr 27th, 2006, 04:24 PM
#9
Thread Starter
Junior Member
Re: Print button
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|