Solved

MSHFlexiGird. How To Add Columns At Runtime

Posted on 2000-03-30
7
185 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
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 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