Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to add record in grid
Message
De
24/08/1999 00:57:50
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00256366
Message ID:
00256936
Vues:
22
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!
* a)
IF ThisForm.AddingMode = .T.
   Go -1  && Jump to Fresh adding Record
Endif

If RecNo() < 0   && Just Fresh Add record
   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  && Yes
         oGrd.Column1.SetFocus
         Return  && Skip following Code
      Case nRes = 7  && No
         =TableRevert(.F.)
         * Go ahead Following code to add again!
      Otherwise
         =TableRevert(.F.)
         ThisForm.AddingMode = .F.
         Return && Skip Following Code
      EndCase
   Else
      Wait Window NoWait "Record Saved!"
      =TableUpdate(.T.)
   Endif
Endif

Append Blank
ThisForm.AddingMode = .T.   && Some Adding Record in Buffer (New Property!)
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform