Difficult Flexgrid question ?

VBKid04
04-14-2004, 11:20 AM
I have a recordset called customerRS that I want to be displayed in a flexgrid.

The difficult(?)/confusing part is...
I want to use a SQL query which will SELECT * WHERE CustomerID=1
(so this gets all fields where CustomerID=1)

but I only want to display the first 2 fields for each record on the flexgrid (which are called CustomerID and CustomerName).

This will allow the user to scroll through the Flexgrid seeing only the CustomerID and CustomerName, rather than lots of data they don't need to know about.

When the user selects 1 row on the Flexgrid though, and clicks a command button (cmdDisplay to display the entire record), I want the ENTIRE record (everything that was selected in the original SQL query) to be displayed in appropriate textboxes.


Firstly, Im not sure how to display only 2 fields of the entire recordset on the Flexgrid.

I can populate my grid with all fields using the code supplied here:
http://www.xtremevbtalk.com/showthread.php?t=35110
(under Show Table data in MSFlexgrid - perhaps someone can explain to me what I must change in this to display only the first 2 fields)


Secondly, after I have displayed only 2 fields on the flexgrid, would it be better to say something like (this pseudocode):

Where Flexgrid Selected value in Column1 (which is one particular CustomerID) = customerRS(CustomerID)

customerRS.Send all matching fields to textboxes

?


Does this make sense?

Only problem is, how do I go about this ?


Thanks for any help.

CrystalWizard
04-14-2004, 11:40 AM
My advice would be to populate the grid with all of the information from the recordset if it is not too much info. Then use the

.colhidden(#) = true

property to hide all of the columns that you do not want to appear. That way the info is still there but out of sight.

When you compare

Column1 (which is one particular CustomerID) = customerRS(CustomerID)

compare by row if it is a standard left to right type grid.

Dim row

with nameOfGrid

Row = .MouseRow ' will get current selected row
if(.cell(flexcpText,Row,#) = customerRS(CustomerID)) then
' # being the column that you want to use for comparisons
.
.
.

This should get the row of info you are looking for and from here you can manipulate that row's data

VBKid04
04-14-2004, 12:20 PM
Crystal wizard its not liking the .ColHidden property.

Comes up with a compile error saying:
Method or Data member not found.

pointing to the line:
.colhidden(1) = true (and highlighting .colhidden)


Maybe I am missing some component that needs to be installed?

Please help (anyone), am in urgent need to get this working as its holding me up.

CrystalWizard
04-14-2004, 12:57 PM
Here are the relevant references I'm using

VideoSoft VSFlex 6.0 Controls (OLEDB)

components:
VideoSoft VSFlex 6.0 Controls (OLEDB)
VideoSoft VSFlex 6.0 Controls (OLEDB/Unicode)

Are you using these?

VBKid04
04-14-2004, 02:54 PM
CrystalWizard no sorry I dont have any of those, only have what came with the VB installation and those don't seem to be there.

Anything else I can use ?

CrystalWizard
04-14-2004, 03:04 PM
The other method would be to populate just the first two columns by only pulling certain items from the recordset (i.e a unique record identifier and name)

Populate the grid with this information. Use the same methodology as before

Dim row

with nameOfGrid

Row = .MouseRow ' will get current selected row
if(.cell(flexcpText,Row,#) = customerRS(UniqueID)) then
' # being the column that you want to use for comparisons
.
.

Except here you want to take the unique ID number from that row and search for it in the recordset. When located, grab that record and feed it into your text boxes.

Give it a shot and if it doesn't work, post some code of your project

msmeth
04-14-2004, 03:39 PM
With the Flexgrid, the .ColWidth(Index) property can make a column appear hidden. .ColWidth(1) = 0 will hide the first column...try that for each that you want to not be visible...

Flyguy
04-14-2004, 03:58 PM
Here are the relevant references I'm using

VideoSoft VSFlex 6.0 Controls (OLEDB)

components:
VideoSoft VSFlex 6.0 Controls (OLEDB)
VideoSoft VSFlex 6.0 Controls (OLEDB/Unicode)

Are you using these?
These are commercial controls which are not included with VB6

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum