Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid for DataEntry?

Status
Not open for further replies.

handoko

Technical User
Apr 18, 2003
24
ID
Hi again,
I need a suggestion. I make a master detail form. For Detail DataEntry I use grid.
Which one better?
1. Entry Data to the Grid Directly. I see a lot of problems here. I'd try once. It's dificult in validition. Sometimes I have to left one blank record.
2. Use some textboxes to verify the record validation. If valid then put into grid with command button.So there's no unvalid record in detail grid.
I'm still hope can use choice no 1. It's look good design interface for me.
Any idea or example to do it?

Thanks guys.

Handoko
 
Handoko,

My preference would be to use the grid to display the data, but not to let the user edit it (for the same reasons that you gave).

Instead, I would let the user double-click on the row they want to edit. This would launch a modal dialogue which lets them edit that one record. When they close the dialogue, the edited data will appear in the grid.

Mike


Mike Lewis
Edinburgh, Scotland
 
Thanks Mike Lewis,
I've ever try a POS SYSTEM program made with Clipper for DOS. it use a grid directly for data entry. No matter what we put unvalid record, when we ended the Entry proses (by push Save button for example). The grid automaticaly just shows the valid record only.

Is there a way to do that in VFP?.
I know the grid in VFP directly access the table or view.I think it's the reason why it's become dificult.

Maybe using a temporary detail table, or temporary Grid, or something else while add/edit the detail records. But when we "save" them, they will filtered become valid record only.

Any Suggestion / Comment?

Handoko

 
Handoko,

There are a couple of things for you to consider:

- Write code in the Valid event of the textbox (that is, the textbox that is inside the column of the grid). This event is fired as soon as the user moves focus away from the cell.

- Use buffering on the underlying table or view. This is better than using a temporary table. With buffering in force, you can issue a TABLEREVERT() if you want to cancel the changes that the user makes.

You can buffer either a single row or the entire table. With a grid, table buffering makes more sense. Once the editing is finished, issue TABLEUPDATE() to commit the edits (typically, you do this in the Save button).

Hope this helps.

Mike


Mike Lewis
Edinburgh, Scotland
 
Mike,
What is the differences between using TABLEREVERT(),TABLEUPDATE() with BEGIN TRANSACTION,ROOLBACK,END TRANSACTION.

Could you give me an example code using TABLEREVERT() and TABLEUPDATE() implement in the grid?

Thanks
Handoko
 
Handoko, I m working on a similar project. I m not allowing the user to enter the data directly In Grid. I use the TextBoxes and when the user press ENTER on the last textbox, the validated data inserted into the grid. NOw if the User press REVERT, i use:

SELECT purchases
TABLEREVERT(.t.)
SELECT pdetail
TABLEREVERT(.t.)

------But before this u must set the Table Buffer property to 5 (Optimistic Table Buffering). Then u can user Tableupdate or Tablerevert.
In order to Edit a record in a Grid. I have 4 special button for GRID (Vertically in form at the side of the Grid.0 THese buttons are smaller then the usual buttons. These buttons are initially Disable. When the user press EDIT, these buttons become ENABLE. So IF the user wants to edit a record in master, the user will change the value on the relevent textbox. But if the user wants to edit a record in grid, he may use the special buttons which are(UP,DOWN,ADD,DEL) in a grid. UP / DAWN for row navigation. When he presses up/dawn the current data from current row displayed in the textboxes which were used for validated data entry in grid. so the user then chage the data accordingly and again when the user press ENTER on the last textbox, it will update the related row in grid. here if the user press REVERT the data will change on its original state. But keep it in your mind that whenever u edit a data lock the particular record for example i do :

set reprocess to 1 seconds
SELECT purchases
mrecno = RECNO()
IF LOCK(mrecno) = .F. then
MESSAGEBOX("Record is being updated by another user....")
ELSE
(routine which enabled the special buttons and other textboxes for edition)
ENDIF

-------- this is because the OPTIMISTIC TABLE BUFFERING lock a table only when the tableupdate / tablerevert is implied. If u do not lock the record manually, it is possible that 2 users could change the same data at the same time, in this situation the data updated by the last user who press SAVE will be in the table and the updation by the 1st user will have no effect.

I hope my suggestions and idea will help u a lot.
 
Handoko,

What is the differences between using TABLEREVERT(),TABLEUPDATE() with BEGIN TRANSACTION,ROOLBACK,END TRANSACTION.

TABLEREVERT() and TABLEUPDATE() are used with buffering. When buffering is enables, each time you start editing a record, it is copied to a memory buffer. The update is not committed until you issue TABLEUPDATE(). Or you can cancel the update by means of TABLEREVERT().

You use buffering to:

- Validate the edits before they are committed.

- Give the user the possibility of reverting the edits.

- Dealing with multi-user conflicts.

The TRANSACTION commands are used with transaction processing. You use transaction processing to:

- Ensure that a related group of updates work together -- if one fails, they all fail

- Guard against the effects of power failures, program crashes, etc. If these things happen, you won't be in a situation where your tables are only part updated. Either they are all updated or none of them is.

That's a very simplistic explanation. My advice would be to concentrate on learning buffering first, and come to transactions later.

Mike


Mike Lewis
Edinburgh, Scotland
 
Peping,
Rafael Copquin use cursor for temporary grid.
Then do scanning record to filter the valid record put into the real table.
I try to do the same thing but without Cursor just using table buffering.

My algorithm:
1. CURSORSETPROP('Buffering',5,'Detail')
2. do edit, append, or delete in the grid.
3. SCAN FOR DETAIL.NO=MASTER.NO
IF NOT VALIDRECORD
IF RECNO()<0 &&MEANS APPEND IN THE BUFFER
TABLEREVERT()
SKIP -1
ELSE
DELETE &&EDIT EXIST RECORD
ENDIF
ENDIF
ENDSCAN
TABLEUPDATE(.T.)

It works.

But I wonder, where do i put TRANSACTION?
Mike could you help me?

Handoko
 
I have a grid I created and entries are made to the grid via textboxes and an addtogrid button.

If the user wants to edit, they click edit and it highlights the first row in the grid from there they can scroll up and down.

I'm sure this is really easy but how do you get the row they select back into the textboxes to edit?

Thanks in advance for the help!
 
Kerbouchard !

U can add two buttons at the side of the Grid. 1 for UP and 1 for DOWN. and for example i m using the following code for the UP.

SELECT detail
SET filter TO detail.sno=thisform.txtno.value
IF NOT BOF() THEN
SKIP -1
thisform.txtDescr.value = detail.descr
thisform.txtQty.Value = detail.qty
thisform.txtRate.Value = detail.rate
thisform.txtGstRate.Value=detail.gstrate
thisform.txtGstValue.value=detail.gst
thisform.txtAddGstRate.Value=detail.addgstrate
thisform.txtAddGstValue.value=detail.addgst
thisform.txtTotal.Value = detail.amount
thisform.txtDescr.SetFocus
ENDIF
-------------------------------------------------
this code skip to the previous record on grid, and shows its contents to the relative text boxes. I hope u will understand this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top