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
Solved

Printing a cell from a DBGrid

Posted on 1998-09-27
4
156 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

809 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