[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Using DBGrid Like A Spreadsheet

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
nu2vb
Asked:
nu2vb
  • 3
  • 2
  • 2
  • +1
1 Solution
 
MirkwoodCommented:
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
 
nu2vbAuthor Commented:
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
 
MirkwoodCommented:
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!

 
nu2vbAuthor Commented:
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
 
advancefiberCommented:
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
 
nu2vbAuthor Commented:
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
 
bear454Commented:
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
 
bear454Commented:
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!

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now