Solved

Printing a cell from a DBGrid

Posted on 1998-09-27
4
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

735 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