Hi,this is my code for print data to my default printer,but not for all data.
1.How to print all data from datagrid to printer? -
Private Sub Command2_Click()
-
-
Dim RRow As Integer
-
Dim Colomn1 As Integer
-
-
DataGrid1.row = 0
-
DataGrid1.Col = Colomn1
-
For Colomn1 = 0 To DataGrid1.Columns.Count - 1
-
DataGrid1.Col = Colomn1
-
Debug.Print DataGrid1.Text
-
-
Next
-
-
Colomn1 = 0
-
DataGrid1.Col = Colomn1
-
For RRow = 0 To 5
-
DataGrid1.row = RRow
-
For Colomn1 = 0 To DataGrid1.Columns.Count - 1
-
DataGrid1.Col = Colomn1
-
Printer.Print DataGrid1.Text
-
Next
-
Next
-
-
Printer.EndDoc
-
-
End Sub
-
11 10092
Not sure what you mean. What does this code not print, that you want it to?
sorry make you confused, my question is how to print all data from datagrid to my default printer?
@hwkong1688
All you've done is repeat the original question. It doesn't give us enough information to work with.
We need more detail to understand exactly what you want from us. You've shown us code which prints data to your default printer. As far as I can tell, you already have exactly what you're asking for. What is it about this code that you're not happy with? What does this code not do, that you want it to? In what way does your existing code not "print all data from datagrid to my default printer"? Please explain.
Sorry my english not so well could be make you don't understand want i mean. you can check back my first post #1 line 16 [For RRow = 0 to 5] this is can only print 6 data from my datagrid to my default printer. How to print all data to my printer. This is my question?
Can't you apply the same technique used in line 18, but using Rows.Count instead of Columns.Count?
NeoPa 32,556
Expert Mod 16PB
Thread moved from the Insights forum to the Answers forum. Please be more careful in future where you post your questions to (This is certainly not an Insight).
Sorry noted NeoPa,When i changed Columns.Count to Rows.Count i got this error msg: Compile error:invalid qualifer
Damn, how do you determine the number of rows (or should that be "records") in a datagrid? I haven't worked with them in years.
Anyone?
this is how to collect data from a datagrid -
Option Explicit
-
'§ add reference= Microsoft ActiveX Data Object 2.8 Library
-
'§ C:\Program Files\Common Files\system\ado\msado15.dll
-
-
Dim ADO_RECSET As ADODB.Recordset '§ Create a Recordset
-
-
Private Sub Form_Load()
-
Set ADO_RECSET = New ADODB.Recordset
-
ADO_RECSET.CursorLocation = adUseClient
-
' Add columns to the Recordset
-
ADO_RECSET.Fields.Append "Key", adInteger
-
ADO_RECSET.Fields.Append "Field1", adVarChar, 40, adFldIsNullable
-
ADO_RECSET.Fields.Append "Field2", adDate
-
' Open the Recordset
-
ADO_RECSET.Open , , adOpenStatic, adLockBatchOptimistic
-
' Add data to the Recordset
-
ADO_RECSET.AddNew Array("Key", "Field1", "Field2"), _
-
Array(1, "string1", Date)
-
ADO_RECSET.AddNew Array("Key", "Field1", "Field2"), _
-
Array(2, "string2", #1/1/2000#)
-
' Populate the Data in the DataGrid
-
Set DataGrid1.DataSource = ADO_RECSET
-
End Sub
-
-
Private Sub ComPrint_Click()
-
Dim FIELDSidx As Integer
-
Dim ITEMidx As Integer
-
Dim DATA As String
-
ADO_RECSET.MoveFirst
-
Do Until ADO_RECSET.EOF = True
-
DATA = DATA & vbCrLf
-
For ITEMidx = 0 To ADO_RECSET.Fields.Count - 1
-
DATA = DATA & ADO_RECSET.Fields.Item(ITEMidx).Value & " - "
-
Next
-
ADO_RECSET.MoveNext
-
Loop
-
Text1.Text = DATA
-
End Sub
-
Instead of putting the data in the textbox, send it to the printer.
Seems as though the whole recordset creation thing is rather clouding the issue here.
If I'm not mistaken, the point you're making is that there is no record count, and one must simply loop through all the records. Correct?
Yes, there are different types of grids in VB but for the datagrid like in your call, the way to read the records is to go to the first one, read it, go to the next one, ... until EOF. (see demo attached)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Spire |
last post by:
Does anyone know how to print on POS printer (on com port) from C# (other
than using dos command type x.txt>com1)?
I have attempted with this but nothing happens
IntPtr ptr= CreateFile("COM1",...
|
by: Paresh |
last post by:
Hi
I need to Print asp:datagrid with formatting, which will
avoid my writing of crystal reports and can directly
print with click of a button.
any kind of information is appreciated
Thanks...
|
by: Paresh |
last post by:
Hi
I need to Print asp:datagrid with formatting, which will
avoid my writing of crystal reports and can directly
print with click of a button.
I do not just want to print the current page, I...
|
by: Mitul |
last post by:
Hello friends,
I am getting stuck at a point in my project.
I would like to give functionality of print data from site. but there
is a problem is that if there are lots of data which takes...
|
by: ranu s |
last post by:
M trying to print image by calling print api (web based application )
As my knowledge is concerned aspnet account wont provide access to
netwrk printers .......
My questn is
1)How to print...
|
by: hariharanmca |
last post by:
any know how to Print data through Store Procedure to the printer Directly
|
by: printline |
last post by:
Hello Guys
I cannot print from a locally installed printer that is mapped to a windows 2003 sever.
I have installed the printer locally and can print locally. I connect to the windows 2003...
|
by: vicky87.eie |
last post by:
I need to print the image i have drawn in a picture box. My program is
create an application similar to paint in windows, I used picture box
as the area to draw. Now after completing the work i...
|
by: =?Utf-8?B?SmJhcmJlcg==?= |
last post by:
All users in my XP Professional PC were able to print to a network printer
until now. Now, the only account that can print to the network printer is the
admin account. I have an HP PSC 2200 series...
|
by: Zulqarnain |
last post by:
I have developed a report in developer 6i. It properly prints on laser printer but it do not print on receipt printer (CZERLOP).
Printing job has sent to printer & printer also detect this job but...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |