Solved

MS FlexGrid

Posted on 2001-06-15
8
148 Views
Last Modified: 2010-05-02
I have designed a page which can be used to input employee details. I added a MSFlexGrid to that page,in which i wanted to add the records.

My problem is, after entering the record I will save that record. So, once it is saved it should display in that MSflexGrid. How  to do this????

I tried it is getting saved, but at the same time it is not appearing in MSFlexGrid. Once u close the program and then open the same u can find the saved record displayed in MSFlex.

So, what should I do, if I want to see my records in MSFlexGrid immediately when i saved a record.

....Ravi.
0
Comment
Question by:kudamala
8 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6194458
There are a number of ways to do this. If you have a recordset bound to the flexgrid then after the new record has been added you will need to refresh the recordset and then reassign it to the flexgrid:

ADODC1.Refresh ' If using ADO Datacontrol
Data1.Refresh ' If using Intrinsic data control
Set MSFlexgrid1.DataSource = ADODC1 ' Or Data1 depending on data control in use.

This should redisplay the grid with the newly added record showing.
0
 
LVL 14

Expert Comment

by:puranik_p
ID: 6194685
Hoe about using a datagrid instead of MSFlexgrid?
keep it updatable and you don't have to write code for refreshing ADODC or the grid.
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6194688
If you are using, recordset, try:

rs.requery
(or)
re-open the recordset again.
and bind it to the MSHFlexGrid again.

You can also try like this for ADO Data Control:
ADODC1.Recordset.Requery

Cheers.
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6194692
sorry, not MSHFlexGrid, its MSFlexGrid, right?
0
 
LVL 50

Expert Comment

by:Ryan Chong
ID: 6194906
hi kudamala, MSFlexGrid control only compatible with intrinsic data control and remote data control such as Data Control and Remote Data Control (RDO), but not with ADODC.

You can pair MSFlexGrid with either Data Control or RDO by set its DataSource property.
0
 

Expert Comment

by:sureshpodaralla
ID: 6199385
Public Sub FlexiGridDisplay()

    ' Make room for column widths.
    num_cols = rst.Fields.Count
    ReDim col_wid(0 To num_cols - 1)

    ' Set column headerst.
    frmScan.flxResults.Rows = 2
    frmScan.flxResults.Cols = num_cols
    frmScan.flxResults.FixedCols = 0
    frmScan.flxResults.FixedRows = 1
    For c = 0 To num_cols - 1
       ' frmScan.flxResults.TextMatrix(0, c) = rst.Fields(c).Name
        frmScan.flxResults.TextMatrix(0, 0) = "Col1"
        frmScan.flxResults.TextMatrix(0, 1) = "col2"
        frmScan.flxResults.TextMatrix(0, 2) = "col3"
        frmScan.flxResults.TextMatrix(0, 3) = "col4"
        frmScan.flxResults.TextMatrix(0, 4) = "col5"
        frmScan.flxResults.TextMatrix(0, 5) = "col6"
        ' See if we need to enlarge the column.
        new_wid = frmScan.TextWidth(rst.Fields(c).Name)
        If col_wid(c) < new_wid Then col_wid(c) = new_wid
    Next c
    r = 0
    Do Until rst.EOF
        r = r + 1
        frmScan.flxResults.Rows = r + 1
        For c = 0 To rst.Fields.Count - 1
            ' if there is something in column
            If (Len(rst.Fields(c).Value)) Then
                frmScan.flxResults.TextMatrix(r, c) = rst.Fields(c).Value
                ' See if we need to enlarge the column.
                ' new_wid = Len(rst.Fields(c).Value)
                new_wid = frmScan.TextWidth(rst.Fields(c).Value)
            Else
                ' otherwise, use blank. if we don't do this
                ' it will die because of the invalid use of Null
                frmScan.flxResults.TextMatrix(r, c) = " "
                new_wid = 0
            End If
           
            ' Which ever is bigger that is going to be the new
            ' current col_wid(c)
           
            If col_wid(c) < new_wid Then col_wid(c) = new_wid
        Next c
        rst.MoveNext
    Loop
End If

    ' Set the grid's column widths.
    For c = 0 To num_cols - 1
        frmScan.flxResults.ColWidth(c) = col_wid(c) + 120
    Next

    ' Display the grid.
    frmScan.flxResults.Visible = True
   
    rst.Close
End Sub


I hope this will help you

Thanks,
suresh podaralla
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7136167
Hi kudamala@devx,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept TimCottee's comment(s) as an answer.

kudamala@devx, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7173324
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input past end of file vbs script 9 92
Excel VBA combine two working workbooks 8 53
Put text in a picture ASP.NET C# 2 56
vb6 connector to SQL Server 2 37
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

776 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