Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Printing a cell from a DBGrid

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 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…
Suggested Courses

604 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