?
Solved

MSHFlexiGird. How To Add Columns At Runtime

Posted on 2000-03-30
7
Medium Priority
?
194 Views
Last Modified: 2010-05-02
I am using a MSHFlexiGrid to which I am allocating a recordset at run time. I don't want to display all the fields returned from the recordset in the MSHFlexiGrid but want to select which ones to display at runtime. How do I do this?
0
Comment
Question by:Shandy
[X]
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
7 Comments
 

Expert Comment

by:jayaraghu
ID: 2668854
HI,
you can just assign the field name to the grids cell.
for example,
if your query is
strsql="select * from StudentsTable"
set recordset=...

the table contains 5 fields, namely
studentid, studentname, studentDOB, studentcourse, studentgrade.

you want to display studentid and studentname in the grid.

for row=1 to recordset.recordcount-1
for col = 0 to 1
msflexgrid1.textmatrix(row,col)=recordset(col)
next col
next row

i hope this is what u expect.
good luck
JayaRaghu
0
 

Author Comment

by:Shandy
ID: 2668979
Not quite what I was after. I want to bind the MSHFlexGrid at runtime to a recordset and then only display certain columns/fields from the recordset in the MSHFlexGrid. I want the MSHFlexGrid to populate itself from the datasource I set at runtime (which it does), not assign field values manually to the MSHFlexGrid.
0
 
LVL 6

Expert Comment

by:Marine
ID: 2669099
Ok say your recordset will retrieve 100 records at once. But you want only to show 10 at first and when click next load the next 10 ? There is something called "Paging" Set the cachsize of recordset = to 10 then use pagecount property and in a loop you move though the records. Post your reply if this what you need i will give an example.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Shandy
ID: 2669159
I'm afraid I'm not explaining this very well.

Try this example.
I want to use a recordset containing the fields:
forename, surname, Identity Number
I want to bind the MSHFlexGrid to this recordset at run time but only display forename and surname. By default it seems to display all 3 fields.

I know I could set up 2 separate recordsets but it just seemed a waste of resource if I could get the MSHFlexGrid to run off a recordset I already had open.
0
 

Accepted Solution

by:
mfclaes earned 100 total points
ID: 2670481
Hi Shandy

I might understand this wrong but if I get it right, then I suggest this

if you assign  your recordset like this

strsql="select * from StudentsTable"
set recordset=...

then you can do the following thing:

strsql="select forename, surname from StudentsTable"
set recordset=...

or just set the width of your third column to 1, so it is there but you won't see it





0
 
LVL 6

Expert Comment

by:VBGuru
ID: 2672329
Lets say you have 3 fields in your recordset namely f1,f2 and f3
and you don't want to display the field f2
So you will query the database like this
"select f1,f3,f2 from table"

and you will set the flexgrids colms as this
MSFlexGrid1.Cols = 2
so the last column is removed from display. So make sure to get the fields which you don't want to diaply at the last.


Hope it will help.
0
 

Author Comment

by:Shandy
ID: 2672578
Setting the width to 0 works. Obvious as soon as you pointed it out to me!
Thanks
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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

649 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