Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating MSFlexGrid (Newbie Question)

Status
Not open for further replies.

Jasonic

Technical User
Jun 20, 2001
69
GB
Dear All

I have and application that retreives data based on a freeform query, therefore the number of columns returned varies depending upon the query.

I would like to adjust the number of columns depending upon the query.

I.e.
Code:
iCounter = (No of Columns)
MainFrm.Datagrid.cols = iCounter

' Populate the headers information
For iIndex = o to iCounter
  With MainFrm.Datagrid
    .Col = iIndex
    .Row = 0
    .Text = "<<Some text goes here>>"
  End With
Next iIndex

When running the application, a compile error is generated at the .col = iIndex line


Jason Thomas
AssetCenter Consultant
Jason Thomas Consultancy Limited
:)
 
Hi,

If your query is returning a recordset you could set the data in the grid like this...
Code:
Set DataGrid1.DataSource = <YOUR RECORDSET>
Datagrid1.Refresh

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
It would work but this would require you to leave the recordset open to keep the grid populated and that isn't the best practise in the world by any means...

Harleyquinn

---------------------------------
For tsunami relief donations
 
HarleyQuinn

Thanks for the prompt response, but I'm not using recordset.
I'm using a .dll and a module that has the functions etc defined to retreive the data.

Basically, the dll creates a cursor on a table and then using querynext you can cycle through the data pointed to by the cursor.

Thanks

Jason Thomas
AssetCenter Consultant
Jason Thomas Consultancy Limited
:)
 
Hi,

You could try changing the following lines:
Code:
For iIndex = o to iCounter
to
For iIndex = 0 to iCounter - 1

That seems to work for me now.

Hope this helps


Harleyquinn

---------------------------------
For tsunami relief donations
 
I'm sure that it's just a Typo, but if you've copied and pasted, then:
Code:
For iIndex = o to iCounter
is using the variable 'o' for it's start point, rather than value 0

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Johnwm

Yes it is a typo

In fact the line should read
Code:
For iIndex = 0 to icounter - 1

Unfortunately, I'm reading this forum at work, with the VB at home.

Jason Thomas
AssetCenter Consultant
Jason Thomas Consultancy Limited
:)
 
Sorry Harley - I seem to have posted at the same time!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Thanks for the help

I have discovered the problem, lies with the .Row = 0 statement. I have this and now everything is back on track.

Jason Thomas
AssetCenter Consultant
Jason Thomas Consultancy Limited
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top