Solved

Using DBGrid Like A Spreadsheet

Posted on 1998-11-30
8
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

749 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