I agree with you!
First of all, the coding for Last Columns.LostFocus to add record is not the
right Event on adding new record.
Even, user don't want to add record, and {Tab} away, it still add record!! +_+
I would suggest 2 events to do:
a) Add Code on oGrd.Column##Last.Text1.KeyPress
b) oForm.KeyPress with KeyPreview is True (Handle all key-input)
Only Add record if user press Enter!
IF ThisForm.AddingMode = .T.
Go -1
Endif
If RecNo() < 0
If Empty(mainKey1) or Empty(mainkey2)
nRes = Messagebox("Yes to Edit this Record/No to Delete this Record & Re-add again/Cancel to Stop adding record!",3,"Empty Record Found!")
Do Case
Case nRes = 6
oGrd.Column1.SetFocus
Return
Case nRes = 7
=TableRevert(.F.)
Otherwise
=TableRevert(.F.)
ThisForm.AddingMode = .F.
Return
EndCase
Else
Wait Window NoWait "Record Saved!"
=TableUpdate(.T.)
Endif
Endif
Append Blank
ThisForm.AddingMode = .T.
Replace ChildTable.mainKey1 With FatherTable.mainKey1
oGrd.Column1.SetFocus
Make Sure No empty Record is tableUpdate!!
p.s. I Still not try this code, just think in the fly! ~_^
>I've done what Cetin has suggested to you in one of my apps. An additional note to this is when saving remove any blank records before tableupdate(). You can do this a couple of ways:
>
>1. Issue a DELETE FOR .... to remove blank records and TABLEUPDATE(1) to update all changes at once
>2. Do a GETNEXTMODIFIED() loop and TABLEUPDATE() or TABLEREVERT() each record accordingly.
>
>>First of all, thanks a lot of your response !
>>
>>the controlsource of grid is table, and buffer mode=5, I would like
>>to the grid can automatic add blank record while the user press entry
>>in last grid column.
>>
>>
>>>>How to add record when the cursor lost focus in last column?
>>>
>>>More information please...
>>>
>>>Is the record source of the grid a table, a view, or a cursor ??? Is the record source updatable, and is it still selected ???
>>>
>>>Regards,
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.