[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Populate a DBGrid via a text file

Posted on 2000-02-01
7
Medium Priority
?
225 Views
Last Modified: 2010-05-02
Hi
I need to populate a dbgrid using a text delimitted file. Also the users must be able to edit the grid and therefore edit the text file.
I am copying or recreating a program where my client lost the source code. The previous developer was populating a grid using a text file. But now my client also wants to be able to edit the values in the grid

thanx
:)

Craig

0
Comment
Question by:CraigLazar
7 Comments
 
LVL 8

Expert Comment

by:stefanx
ID: 2477880
I can suggest using an uprated MSFlexGrid called axgrid. The latter is effectively an MSFlexGrid that allows you to edit the grid. It is not a DBGrid, but the editing is enough to make it useful.

As for getting the textfile in, if the delimiters are tabs, then it is simply a matter of reading the file line by line as follows :

F = FreeFile
Open "c:\whereisit.txt" For Input AS #F
While Not F.EOF
  Line Input #F,Tmp
  Grid1.AddItem Tmp
WEnd
Close #F

To update the text file, you'll need to write the entire file.

To locate axgrid, just search for it on the net. If you can't find it, let me know so that I can upload it to some or other server.

The suggested solution is not ideal (a DBGrid operating on a textfile would be nicer), but if no one answers or your client is breathing down your neck, give it a bash.
0
 
LVL 18

Expert Comment

by:deighton
ID: 2477986
How about importing the grid to a db then editting it using a grid, export back to text file.
0
 
LVL 71

Expert Comment

by:Éric Moreau
ID: 2478237
Just an idea but it is worth trying!

Populate an in-memory ADO recordset and bind it to a DataGrid control. Then place a button that will recreate the delimitted text file from the recordset!
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 4

Expert Comment

by:inpras
ID: 2478283
How about using ODBC Text driver best for UR case I believe
inpras
0
 
LVL 2

Expert Comment

by:AndySulz
ID: 2480531
Look, DBGrid means DataBaseGrid, not TextGrid.  you can make your own grid control via text box control arays.
0
 
LVL 4

Author Comment

by:CraigLazar
ID: 2517791
Thanx but idecided to use a dbgrid and rather populate it from an access database, now just gotta see if the client is happy with it

thanx for all the input though
:)

Craig
0
 
LVL 1

Accepted Solution

by:
Catouch earned 100 total points
ID: 2534813
Here's some code to be able to edit a grid, (just in case you need it)

Private Sub GridProps_DblClick()
    Dim RowCounter          As Integer
    Dim Offset              As Single
    Dim RowOfInterest       As Integer
    Dim TmpBtn              As CommandButton
   
    For Each TmpBtn In BtnQuit
        TmpBtn.Enabled = False
    Next
   
   
    tbsOptions.Enabled = False
   
   
    With GridProps
       
       
        .Enabled = False
       
        RowOfInterest = .Row
        For RowCounter = 0 To RowOfInterest - 1
            If .RowIsVisible(RowCounter) Then
                Offset = Offset + .RowHeight(RowCounter) + 15 'gridlines
            End If
        Next
       
        txtEdit.Move .Left + (.Width / 2), .Top + Offset, (.Width / 2), .RowHeight(RowOfInterest)
        txtEdit.Text = .Text
        txtEdit.Visible = True
        DoEvents
        txtEditKotteke.SetFocus
        txtEditKotteke.ZOrder vbBringToFront
        .Col = 1
       
    End With

End Sub

0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

591 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