Solved

Using DBGrid Like A Spreadsheet

Posted on 1998-11-30
8
197 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
 

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
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

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

706 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

17 Experts available now in Live!

Get 1:1 Help Now