Solved

Using DBGrid Like A Spreadsheet

Posted on 1998-11-30
8
198 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

815 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

8 Experts available now in Live!

Get 1:1 Help Now