Solved

Printing a cell from a DBGrid

Posted on 1998-09-27
4
153 Views
Last Modified: 2010-04-30
I have a database with 10 fields (fd1, fd2, fd3 etc.) and I want to print the first 3 fields from a record in a DBGrid. I wrote Printer.Print DBGrid1.Columns("fd1").Text, DBGrid1.Columns("fd2").Text, DBGrid1.Columns("fd3").Text
When I run the program, I get the first field printed out 3 times, i.e. fd2 and fd3 do not print. Can someone help me work out why this occurs?
0
Comment
Question by:JMaher
  • 2
4 Comments
 
LVL 1

Expert Comment

by:khaledc
ID: 1436925
JMaher,
Your problem is that you did not specify the field that you want to print. By default, the col and row properties are set to Zero. This is why you only getting the first filed to be printed three times. What I suggest is that you specify the row number of the fields and then try to print the columns. You can do that by simply:
DBGrid1.row = 0 'To print the first column
DBGrid2.row = 1 'To print the second column
and so on...

I hope that answer your question.
Regards
0
 

Author Comment

by:JMaher
ID: 1436926
I tried doing what was suggested (using Col rather than Row, a typo I guess), but then I got no printing at all. I amm actually using a picture box to simulate the printer. I have been told by someone else that the syntax I used in my question is correct, and when I told him of my problem he could suggest no answer. He said that he uses this syntax and it works fine. I am at my wits end.
0
 
LVL 2

Accepted Solution

by:
dabellei earned 100 total points
ID: 1436927
If you use a dbgrid wich is link to a data control then use the data control recordset.

Each row is link with a record, so if the user select a record the recordset corresponds to this row.

fd1 =  data1.recordset!fd1
use the recordset to print.


0
 

Author Comment

by:JMaher
ID: 1436928
I am sorry, I must be missing something important here. I have linked my DBGrid to a table in a database, and the DBGrid shows all of the records within the table. I just want to print the first 3 fields in the first record, but I keep getting only the first field printed 3 times. I am unable to understand the answer proposed. Please clarify.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now