Solved

How can I make a FlexGrid editable???

Posted on 2000-04-06
7
171 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 4

Expert Comment

by:Nazdor
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
mr krishna that is what my link tells him, in detail the procedure to use that method
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…

763 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

7 Experts available now in Live!

Get 1:1 Help Now