Solved

How can I make a FlexGrid editable???

Posted on 2000-04-06
7
173 Views
Last Modified: 2010-05-02
Hi,

I'm using the following code to create and populate a felxgrid with information from an Access DB. Can anyone please tell me how to edit the code in order to make the Grid editable. i.e I want to be able to update the info in the Db Table from my form.

Any help or suggestions would be greatly appreciated.
cheers,
ian


Set rs1 = New adodb.Recordset        'create recordset
    rs1.Open "select * from AdministratorPasswords", conn, adOpenKeyset,     adLockOptimistic                             'populate rs with query result


mfgFlex1.Clear 'set grid layout at run-time
    k = rs1.RecordCount
    j = rs1.Fields.Count
    mfgFlex1.Rows = k + 1
    mfgFlex1.Cols = j + 1
   
    With mfgFlex1
        lngRow = 1
        Do Until rs1.EOF
            mfgFlex1.TextMatrix(0, 1) = "Username"
            mfgFlex1.TextMatrix(0, 2) = "Password"
            For lngCol = 0 To rs1.Fields.Count - 1
                .TextMatrix(lngRow, lngCol + 1) = rs1(lngCol)
            Next lngCol
            rs1.MoveNext
            lngRow = lngRow + 1
        Loop
    End With
0
Comment
Question by:shovels
7 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2690506
you will need to create an invisible textbox that moves to the desired cell location and becomes visible when you want to edit the grid
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2690510
rather than post all the code just see this article:
http://msdn.microsoft.com/library/techart/msdn_msflexgrid.htm

cheers!
0
 
LVL 6

Expert Comment

by:Marine
ID: 2690716
as another person mantioned, flexgrid is read-only by default therefore you cannot edit it. You can get around it by placing the textbox into each cell when you click in it. And depending on the cell you click you would place a textbox in there.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:Nazdor
ID: 2692487
Try using a DataGrid instead.

Add an ADO datasource, assign the DataGrid to it, load the datasource's recordset accordingly (which auto loads into the datagrid).  You can lock columns you don't want people to edit etc.

However, I've found it a bit clunky... :-(  So you're probably better off dealing with the extra code and sticking with your flexgrid...
0
 
LVL 5

Expert Comment

by:Voodooman
ID: 2692708
Hi!

The various grids are quite poor in VB from a user edit perspective.

Upgrade to TrueDBGrid is a good start!

I usually Pop up Record Edit forms by clicking an Edit button - allowing edit of the Selected record and close control of what the user is doing.

With the datagrids selecting a record moves the record so its easy to edit the underlying record.

Editing in the grid is clunky and difficult for the user (my opinion only!) nad difficult to control.

Good Luck

Voodoman!


0
 
LVL 1

Accepted Solution

by:
mr_krishna earned 50 total points
ID: 2693468
Put a TextBox control in the form and write the following code. There is no other way to make flexigrid is editable.

With flexgrid1
      If .Col = 2 And .Row <> .Rows - 1 Then
         bCellEdit = True
         txtCell.Top = .Top + .CellTop - 50
         txtCell.Left = .Left + .CellLeft - 50
         txtCell.Height = .CellHeight
         txtCell.Width = .CellWidth + 30
         iLastRow = .Row
         txtCell = .Text
         txtCell.Visible = True
         txtCell.SetFocus
      End If
   End With
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2693528
mr krishna that is what my link tells him, in detail the procedure to use that method
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now