Solved

Using DBGrid Like A Spreadsheet

Posted on 1998-11-30
8
199 Views
Last Modified: 2011-08-18
I need to know how to use either DBGrid or even MSFlex grid for an unlimited data entry screen in VB5.
The grid is 5 columns wide with entry req'd on columns 1 to 4 (with col 5 totalling up cols 4 * 5).

The grid then needs to be written to an Access MDB file.

Any suggestions would be a great help!
0
Comment
Question by:nu2vb
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1447402
Bind it using a data control.
Add a data control to your form
assign the record source
and bind the dbgrid to the data control.
0
 

Author Comment

by:nu2vb
ID: 1447403
Sorry, I wasn't real clear on the question (half asleep when I wrote it!).

I need to use the grid in unbound mode.  I want the user to be able to enter data directonto the grid, not just to change existing data.

I need the grid to be clear for the user to enter text in the first few columns!

I hope this makes a little more sense that my last question!

Thanks for the answer anyway!



0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1447404
Why not use transaction. This way you can revoke the data if you want to.

On form_load the transaction is started. Depending on OK/Cancel the changes are commited or revoked.

Private Sub CommandCancel_Click()
    Workspaces(0).Rollback
    Unload Me
End Sub

Private Sub CommandOK_Click()
    Workspaces(0).CommitTrans
    Unload Me
End Sub

Private Sub Form_Load()
    Workspaces(0).BeginTrans
End Sub
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:nu2vb
ID: 1447405
I will try and add that code to my program (thanks), but I don't think it will fix the first program.

I need the grid to accept user input.  Imagine a grid on a form that's 5 columns wide and say 20 rows high.  I need the user to be able to wither click in the first column (or automatically give it focus), and the user can then type in a code number.  
I want them to be able to tab across and type in a product.  Again, tab across and enter a quantity, then a price, wtc.
When they have finished the first line, I want them to be able to hit enter and the grid geos onto the second row, and the cycle continues, until they press a command button to end!

I presume it possible, I have downloaded a couple of trial version of True DBGris and Sheridans Data Widgets to see if it's easier in them, but I haven't been able to work out how to do it with them either.

Hope this makes some sense!  (Sorry about the long story)





0
 
LVL 1

Expert Comment

by:advancefiber
ID: 1447406
You can use DB bound grid. It will be easy to save the data. The tricky part is that your table shoule be one column more that you need. In grid, you should hide that extra column (do not display that column). When you load form, fill up that extra column with something only. By doing that, you will get a plan grid with all columns empty.

I just try it and it works.

Good luck.

Hong
0
 

Author Comment

by:nu2vb
ID: 1447407
Thanks Hong

Can you please send me a sample of what you mean?
I sort of understand what you mean but I'm still a little confused.

Regards

Gordon

0
 
LVL 1

Accepted Solution

by:
bear454 earned 50 total points
ID: 1447408
1) Query the info into the grid. - Open the recordset, and use a loop to stuff the grid.
2) Change the values. - When the user clicks into the grid, place a textbox on the grid, same size & location as the cell.  When user hits [ENTER], calculate & re-stuff the formula cell.
3) Put the data back. - Immediately or later.
**Immediately - move the cursor in the recordset to the record corresponding to the row on the grid.  Update the value, from the value of the cell.
**Later - put a [Commit] button on your form, then scroll through the recordet, updating each row to the values in the grid.

TaDa!
0
 
LVL 1

Expert Comment

by:bear454
ID: 1447409
Alternatively, embed an Excel Workbook into the form...
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
VBS file using code from 2nd file (txt or vbs) 4 42
VBA/SQL - Connect to SQL server and pull data 4 118
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 58
Hide vba in gp 7 104
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…

839 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