Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: chris smith
  Where is chris smith?
 Yorkshire CH CH
 Barbados
 chris smith
 Tags
Subject: For Eric den Doop
Thread ID: 152 Message ID: 152 # Views: 3 # Ratings: 0
Version: Unknown Category: General VFP Topics
Date: Sunday, May 13, 2001 1:22:01 PM         
   


The following is the code in the beforesave() method:-
*****
kf = thisform.keyfield &&Primary field in table usually unknown to the user.Not shown on the data entry form.
kf2 = thisform.keyfield2 &&Candidate field in table usually known to the user.Shown on the data entry form.
sele 1
if ! empty(kf2)
if empty(&kf2)
return .f. &&EEEError at this point this is returning .t. all the time&&
endif
endif
if empty(&kf)
repl &kf with thisform.newid()
endif
if ! empty(&kf)
return .t.
else
return .f.
endif
***********

The following is the code in the save() method that is using the beforesave():-
*************
if thisform.beforesave()
llret = .t.
t = alias()
amembers(lamembers,thisform.dataenvironment,2)
begin transaction
for each cname in lamembers
if thisform.dataenvironment.&cname..baseclass <> "Cursor"
loop
endif
if cursorgetprop("BUFFERING",thisform.dataenvironment.&cname..alias) > 1
select (thisform.dataenvironment.&cname..alias)
llret = tableupdate(.t.)
else
llret = .t.
endif
if not llret
exit
endif
endfor
if llret
end transaction
else
rollback
messagebox("Save unsuccessfully",16)
endif
sele &t
thisform.viewvalue = 0
thisform.viewrefresh()
append blank
thisform.enable()
thisform.refresh
if ! empty(thisform.focustext)
ft = thisform.focustext
thisform.&ft..setfocus
endif
else
messagebox ("Record Not Saved. Important fields can't be empty.",48,"Invalid record")
endif

**************
smith

ENTIRE THREAD

For Eric den Doop Posted by chris smith @ 5/13/2001 1:22:01 PM
RE: For Eric den Doop Posted by Dale Dedoroy @ 5/14/2001 9:22:50 PM