Solved

Help with DAO Data Grid

Posted on 2004-04-17
5
464 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

12 Experts available now in Live!

Get 1:1 Help Now