Solved

Help with DAO Data Grid

Posted on 2004-04-17
5
466 Views
Last Modified: 2013-12-25
I have an older VB6 program that uses the DAO Data Grid (DBGrid1).  The data source is Data1. The dbgrid96.hlp help file, by the way, is missing.
My question is, how can I change the width of one of the columns? If I do it using the DBGrid1 property pages, the width of the column does change, but the records appear empty.
Can I do it through the program?
Can you tell me where to get the dbgrid96.hlp file?
Thank you.

Eduardo
0
Comment
Question by:EduardoBerger
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 10852368
You can change the width with the mouse at run time, or you can do it programatically.

Private Sub Command1_Click()
Dim c As Variant
'walk through the collection
For Each c In DBGrid1.Columns
    c.Width = c.Width * 1.5
Next c
'or one at a time
DBGrid1.Columns(2).Width = 1000
End Sub

I don't have the help file. I have an old version of the MSDN instead.

0
 

Author Comment

by:EduardoBerger
ID: 10856169
Hi Graham,
Thank you for your answer. It worked fine and the points are yours (please tell me if I need to do something about it).

Is there a way for you to send me the info contained in the file dbgrid96.hlp, or a document that will help me program the DBGrid1? Or a way to get your older version of MSDN (it was not available in the link you gave me).

And one last question on the same topic, if I may. Can I assign a field of a table or query to a specific column of the grid? And can the grid find out what the width of that field is? Thank you.

Eduardo
<email removed Bingie - EE PE>
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 10858011
The EE moderators usually remove any exchange of eMail addresses, but I think if you re-install Visual Studio it should install the help file.

You can select which fields are displayed in which column with the property pages, there doesn't appear to be any way of programatically, either doing that or finding out what was done.  Therefore would recommend changing the order in the recordset query. That way you can find the field width by referring to the column number:

Private Sub Command1_Click()
    Dim c As Integer
   
    For c = 0 To DBGrid1.Columns.Count - 1
        Debug.Print Data1.Recordset.Fields(c).Size
    Next c
End Sub

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

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…
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…
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…

813 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

18 Experts available now in Live!

Get 1:1 Help Now