?
Solved

rows in table to columns in dbgrid

Posted on 2000-02-03
10
Medium Priority
?
251 Views
Last Modified: 2010-05-02
Hello,

I have a table with several rows and I want to display them in a dbgrid as columns. Example: (the text between brackets is the columnheader)

The table looks like this:
[Weeknr]     [Hours]    [Text]
  01                  22         txt1
  02                  12         txt2
  03                  44         txt3

And I want it to be displayed in a dbgrid like this:

[01]  [02]  [03]
 22     12    44
txt1  txt2  txt3

Doe anyone know how to do this?
0
Comment
Question by:Conifeer
  • 5
  • 5
10 Comments
 
LVL 12

Expert Comment

by:roverm
ID: 2485259
Add an ADODC control to your form,
set the properties and connect the DBGrid to the ADODC.
The grid will be filled automaticly !
0
 

Author Comment

by:Conifeer
ID: 2485526
If I do that the dbgrid would look like this:
[Weeknr]     [Hours]    [Text]
  01                 22          txt1
  02                 12          txt2
  03                 44          txt3

But I want the weeknumbers as the columnheaders of the dbgrid.
0
 
LVL 12

Expert Comment

by:roverm
ID: 2485694
Yes, but you can set the columnheader designtime and runtime !
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Author Comment

by:Conifeer
ID: 2486170
How do I set the columnheaders runtime to the weeknumbers?
0
 
LVL 12

Expert Comment

by:roverm
ID: 2487183
Somthing like:

Counter = 0
For i = WeekStart To WeekEnd
  DataGrid1.Columns(Counter).Caption = "Month " & CStr(Counter)
  Counter = Counter + 1
Next i

Be sure to have enough columheader:
Else add them :

Dim col as Column
Set col = DataGrid1.Columns.Add
col.Caption = "Hello"
Set col = Nothing

RoverM

0
 

Author Comment

by:Conifeer
ID: 2489402
Adjusted points to 60
0
 

Author Comment

by:Conifeer
ID: 2489403
Ok, now I have the columnheaders but how do I fill the rest of the datagrid. Do I have to fill it cell by cell and if so, how do I do that.
0
 
LVL 12

Accepted Solution

by:
roverm earned 180 total points
ID: 2489493
Since it is not possible to add rows to a datagrid you have to build a 'help-table':
Build it containing 52 field (named something like NAME1 thru NAME52).
Then write a stored procedure to fill this table:
The first row with all availible week,
the second row with the hours, the third row with the text.
Then connect the datagrid to this table.

Other way: don't use the datagrid but the listview !
Ok, you have to write some code if you want to edit the field, but it's lots faster and you don't have to use the help-table !

RoverM
0
 

Author Comment

by:Conifeer
ID: 2495579
Well, this is the core of my problem. If there is no way to add rows then i would have to use that help table, because there is a lot of editing involved.
Well, thank you anyway for your time.
0
 
LVL 12

Expert Comment

by:roverm
ID: 2495595
You're welcome !

:-) RoverM
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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.
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…
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…

601 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