?
Solved

Printing a cell from a DBGrid

Posted on 1998-09-27
4
Medium Priority
?
162 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 200 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

Technology Partners: 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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

765 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