Solved

msflexgrid format

Posted on 2002-05-21
6
906 Views
Last Modified: 2008-02-01
here is my code..........

If Text1.Text <> "" Then
Dim search As String
Dim myconn
search = Text1.Text
search = Trim$(search)
Set myconn2 = New ADODB.Connection
myconn2.Open "Provider=Microsoft.JET.OLEDB.4.0;Persist Security Info=False;Data Source=c:\farebase\farebase.mdb"
Set myado2 = myconn2.Execute("SELECT farebase.from_1, farebase.to_1 From farebase where farebase.from_1 like '%" & search & "%'order by farebase.from_1 desc;")
Num = 0 + 0
 While Not myado2.EOF
    Num = Num + 1
    myado2.MoveNext
  Wend
End If
MsgBox Num

MSFlexGrid1.Cols = Num + 1
MSFlexGrid1.Rows = Num + 1

how do i set the headers of the columns???

i use this method to add into the cells...........

MSFlexGrid1.TextMatrix(1, 1) = "Hello EE"
MSFlexGrid1.TextMatrix(1, 2) = "Hello EE again"

what is the best way of putting data in, in this format..........


msflexgrid1 col1="text1" , col2="text2" etc etc

in one line, (it is easier for me to understand.

Also when somebosy clicks one specific row, i want the data in a hidden field to be usable..........


(ref ,  col1,   col2,   col3,   etc)
2   ,  name,  address,  tel,    fax
3   ,  fred,  123 road, 3456,   33333

the ref is hodden to the punter, but if they click the row it will bring up a msgbox with the ref num in...

I hope this makes sense, if it does not tell me.

Gavin (AKA Bolox)
0
Comment
Question by:bolox
  • 4
  • 2
6 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7023534
The headers are row zero so you can use:

MSFlexgrid1.TextMatrix(0,1) = "Column One"
MSFlexgrid1.TextMatrix(0,2) = "Column Two"

Use the Click event:

Private Sub MSFlexgrid1_Click()
  Msgbox MSFlexgrid1.TextMatrix(MSFlexgrid1.MouseRow,0)
End Sub

This bit I don't understand, can you clarify?

>> what is the best way of putting data in, in this format..........


msflexgrid1 col1="text1" , col2="text2" etc etc

in one line, (it is easier for me to understand.
0
 
LVL 1

Author Comment

by:bolox
ID: 7023565
actually i do not understand the last bit myself..........so i will not need that after all


the points are your already, for 10 extra points, how can i have the columns autosize to the contents.

for example, in one of my columns the results will always be one char in size and others are only 2 chars, where as the rest may need 20 chars???

if this is not easy, i will up the points

thanx

B

0
 
LVL 43

Accepted Solution

by:
TimCottee earned 150 total points
ID: 7023600
Well you are right it is not that easy but equally not impossible. This snippet will autosize every column of the flexgrid, you just need to adjust the for..next loop to handle the appropriate columns:

Private Sub Command2_Click()
   Dim aryWidths() As Double
   ReDim aryWidths(MSFlexGrid1.Cols - 1)
   For intRow = 1 To MSFlexGrid1.Rows - 1
       For intCol = 0 To MSFlexGrid1.Cols - 1
           If Form1.TextWidth(MSFlexGrid1.TextMatrix(intRow, intCol)) > aryWidths(intCol) Then
               aryWidths(intCol) = Form1.TextWidth(MSFlexGrid1.TextMatrix(intRow, intCol))
           End If
       Next
   Next
   For intCol = 0 To MSFlexGrid1.Cols - 1
       MSFlexGrid1.ColWidth(intCol) = aryWidths(intCol) + 100
   Next
End Sub
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 1

Author Comment

by:bolox
ID: 7023609
you are a star
0
 
LVL 1

Author Comment

by:bolox
ID: 7023611
well deserved points,

speak to ya soon

Gavin
0
 
LVL 1

Author Comment

by:bolox
ID: 7023651
how could i preset the columns to a certain size, knowing there are 5 cols for example,

so, col1 is X big
    col2 is Y  big
   etc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 89
Passing a Text Box name to a Sub 6 99
Export PDF Form fields to Access  or Excel  in Tab order 16 80
backup program with robocopy 6 45
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

828 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