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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data disappears random while saving new record

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
In my datainput screen it happens that sometimes certain fields get blank just prior to get saved.
The datasource is a buffered view. Fields which get blank are both numeric as well as character type.
What might be an efficient wy to trace?
-Bart
 
Olaf, Mike,
The sad thing is that in my application this happens random. I wished I could recall!!
A user reported he added over hudred records without problems but later the error rose again.
-Bart
 
Bart,

With that kind of error occurance's intermittency (if that's the right word, if not - I claim the credit for inventing it! :) ) I'd say with 99.9375% certainty: blame the hardware! (And throw in the Server OS for the good measure as well! :) )
I understand that you have (way, way) more than one client, so it might be a hassle to convince them all to check up and/or upgrade their H/W (especially - network gear), or switch to better ISP if they work remotely, but it well worth the effort.

I remember all too well how our Operations dept. had troubles (intermittent data corruption an/or lost/empty records) with my program (as they thought and gave me more grey hair than IRS) they used for updating data tables on an FS running Win2K Server OS; once they upgraded the network gear, and to Win2003 Server OS - these problems never happened again!

HTH.

Regards,

Ilya
 
Hi Ilya,
be4 you make such a statement: intermittency (if that's the right word, if not - I claim the credit for inventing it!
you better check with Google first next time, as I got 643.000 (!) hits.

For me a much better workable advice would be to install a errortrapping device and construct a trap to catch thie empty record.

Jockey(2)
 
for the records, I fixed the error.
In the gotfocus method I put code to reset the fieldstate .
Code was fault in there.
See thread thread184-1703300 for proper solution.
Down below there is the FAULT code.
When ENTER was clicked in a field several times data was removed during save because fieldstate was manipulated in wrong way.

-Bart

Code:
=DODEFAULT()
LOCAL lcAlias, lcFiedldName, lnBuffermode , lnFldState, lcType, llOK, lnSelect,lNewRecProp

=_ObjectProperties(thisform,this)

this.BackColor = this.oldbackcolor
lNewRecProp = .F.

IF PEMSTATUS(ThisForm,'lNewRecord',5)
	lNewRecProp = .T.
	*=MESSAGEBOX("lNewRecordProperty")
ENDIF 

lcAlias	= ""
IF !EMPTY(this.ControlSource) AND ! 'THISFORM' $ UPPER(this.ControlSource)
	lcType = TYPE( This.ControlSource )
	DO case
	CASE lcType = 'C'
			
		IF ALLTRIM(this.Value) == ALLTRIM(this.uOldvalue)

			* voorlopende spaties weggooien
			this.Value = ALLTRIM(this.Value)
			llOK = .T.
		ENDIF 
	CASE lcType = 'N'
		IF this.Value = this.uOldvalue
			llOK = .T.
		ENDIF 			
	ENDCASE 
			
	IF llOK

		IF '.' $(this.ControlSource)
			lcAlias		 = JUSTSTEM(this.ControlSource)
		ENDIF
		lcFieldName  = JUSText(this.ControlSource)
		
		IF !EMPTY(lcAlias)
			lnSelect = SELECT()
			SELECT (lcAlias)
				lnBuffermode = CURSORGETPROP("Buffering") 
			SELECT (lnSelect)
		ELSE 
			lnBuffermode = CURSORGETPROP("Buffering",lcAlias) 
		ENDIF 			
		
		IF lNewRecProp
		
			IF lnBuffermode > 1
				IF !EMPTY(lcAlias) 	
					lnFldState = GETFLDSTATE(lcFieldName,lcAlias)	
					IF !Thisform.lNewRecord AND (lnFldState = 2 OR lnFldState = 4)
						SETFLDSTATE(lcFieldName,ICASE(lnFldState=4,3,lnFldState=2,1),lcAlias)	
					ENDIF
				ELSE 
					lnFldState = GETFLDSTATE(lcFieldName)	
					IF !Thisform.lNewRecord AND (lnFldState = 2 OR lnFldState = 4)
						SETFLDSTATE(lcFieldName,ICASE(lnFldState=4,3,lnFldState=2,1))	
					ENDIF
				ENDIF 				 
			ENDIF
		ELSE
			IF lnBuffermode > 1
				IF !EMPTY(lcAlias) 	
					lnFldState = GETFLDSTATE(lcFieldName,lcAlias)	
					IF (lnFldState = 2 OR lnFldState = 4)
						SETFLDSTATE(lcFieldName,ICASE(lnFldState=4,3,lnFldState=2,1),lcAlias)	
					ENDIF
				ELSE 
					lnFldState = GETFLDSTATE(lcFieldName)	
					IF lnFldState = 2 OR lnFldState = 4
						SETFLDSTATE(lcFieldName,ICASE(lnFldState=4,3,lnFldState=2,1))	
					ENDIF
				ENDIF 				 
			ENDIF
		
		ENDIF
		
	ENDIF
	

ENDIF

this.BackColor = this.OldBackcolor


IF this.lRequired AND EMPTY(this.Value)
	this.BackColor = RGB(40,200,225	)
ENDIF
 
I haven't looked into the code in detail, but SETFLDSTATE is something you rarely do at all, because the field state automatically changes when users edit data, you only would set a field state to handle single field reverting or something along these lines. It's a bit of tricking VFP to not save a change or change back to OLDVAL() without making VFP save it or something like that. What are you trying to achieve at all?

Bye, Olaf.

 
Hi Olaf,

When I save the form the user gets question save yes/no based upon fieldstates.
If the users changes a field and before saving the record change back than the question for saving is causing question what to save as nothing has changed though?

-Bart
 
Well, you have TABLEREVERT(.F.) to cancel out changes that shouldn't be saved. And if a user wants to save something else, then you simply change a field, fieldstate stays or will change accordingly. The only reason you would need to SETFLDSTATE is, if you give a user a chance to set a field to not saving it, by setting it's state from edited to not edited, but you could also simply put in CURVAL(), so it's save does save what's currently in it anyway.

In short: I don't get what you're asking from your users.

Bye, Olaf.
 
Olaf,
Possibly curval is better than oldval in my case as the changes made by the usere and turned back therefafter do only concern the current session.
Will try this.
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top