How do i print from a listbox?? i'm using Access.

Here's my code for the form to add items to the listbox... I have tried many ways and have failed many times ... Help needed!!

Option Explicit
Dim ItemNumber As String
Dim ItemDescription As String
Dim Qtytoorder As String
Dim AmmendPrice As Currency

Private Sub cmdAdd_Click()
ItemNumber = ITEM_NUMBER.Value
ItemDescription = ITEM_DESCRIPTION_1.Value

AmmendPrice = txtAmmendPrice.Value
Qtytoorder = txtqtytoorder.Value

With lstReorder
.AddItem ItemDescription & " " & ItemNumber & " " & Qtytoorder & " " & AmmendPrice
End With

End Sub

I want to print to a printer please :) so i have a hard copy to scribble on etc.

any help is muc appreciated :)

michael

Error on that code

.text is unrecognised

This is very frustrting. I tried just printing anything...

Printer.Print "Windy1"

And i got runtime error 438
Object doesnt support this property or method.

Is printer.print the correct command?

might be you have not installed your printer driver?

have you??????

Error on that code

.text is unrecognised

that is strange!!!

ok.....then try this,

Dim str as String

str=lstReorder.List(lstReorder.ListIndex)
Printer.Print trim(str)

I tried what you suggested choudhuryshouvi. But still nothing :( so i started at the pure basics and just tried

printer.print "windy"

runtime error 438 - Object doesn't support this property or method.

(i am using microsoft access 2003 by the way)

When i use the exact same code in Visual Basic 6.0, "windy" is printed just as it should be.

Surely printing is a basic function?? so why doesnt it work in access?? confused!

what are you trying actually?

using that Printer.Print command in your VBA program to print some text?

this method is applicable in VB6 programs only.

ok.......could you tell me...

do you have a physical printer attached to your system?

if no then install the default printer for your os. it is Epson Ex-1000. i hope you know how to handle that. try this and come back with ur results..

regards
Shouvik

The coputer uses a network printer, which is properly installed, as i can print from any other program.

i'm going to try to save the data to a file, and then either print from within the file, or print the contents of the file from access... because i have seen in another forum that it is possible to do it that way.

can you be able to print the content from ms-access?

thanks for the help guys :) i found a way around the problem!

I exported the data to a csv file which was more convenient for the end user, and it could be printed from there!

so problem solved kind of.... maybe problem avoided haha

How do i print from a listbox?? i'm using Access.

Here's my code for the form to add items to the listbox... I have tried many ways and have failed many times ... Help needed!!

Option Explicit
Dim ItemNumber As String
Dim ItemDescription As String
Dim Qtytoorder As String
Dim AmmendPrice As Currency

Private Sub cmdAdd_Click()
ItemNumber = ITEM_NUMBER.Value
ItemDescription = ITEM_DESCRIPTION_1.Value

AmmendPrice = txtAmmendPrice.Value
Qtytoorder = txtqtytoorder.Value

With lstReorder
.AddItem ItemDescription & " " & ItemNumber & " " & Qtytoorder & " " & AmmendPrice
End With

End Sub

I want to print to a printer please :) so i have a hard copy to scribble on etc.

any help is muc appreciated :)

michael

The command is Printer.Print -W-H-A-T-E-V-E-R---Y-O-U---P-R-I-N-T
But the location on the page is a bit not likely. So other basic printer commands are:
Printer.CurrentX - sets X-axis location on the paper (in pixels)
Printer.CurrentY - sets Y-axis loc.
Printer.ScaleWidth - returns Width of the paper you use
Pritner.ScaleHeight - returns Height

Printer.Font.Size (also .Bold, .Italic), Printer.Font.Name = "Times New Roman" ... are usual font commands.

When you set currentX positioning and use Printer.Print "Something" the pritnter automaticly sets currentX on next line (which depedns of Font.Size)...

It really needs testing and a expirience, so while testing set "image writer" as default printer - or by 500 pcs. of paper and new cartrige :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.