Welcome! Log In Create A New Profile

Advanced

..NewRecord property not working?

Posted by Tavor 
Tavor
..NewRecord property not working?
April 10, 2009 09:02AM
Hi! I'm having problems whit NewRecord property on file. In help it says that it will be set false when HReset is used and set to true when bunch of actions are used on file such as HReadSeekFirst, but its not working for me. I use HReadSeekFirst to point to record and ..NewRecord property of that file stays true. Is this a bug and is there some workaround (using this property to find out if the record must be is new or not).
Al
Re: ..NewRecord property not working?
April 10, 2009 09:27AM
Hello Tavor

Actually the help in V12 is the reverse of how you stated it works, so it may be a misprint in your version.

NewRecord is set to True by default. This property is also set to True if HReset was used. It is reset to False when one of the following functions is called:
HAdd.
HWrite.
HRead.
HReadLast.
HReadPrevious.
HReadFirst.
HReadSeek.
HReadSeekFirst.
HReadNext.
HModify.
HCross.
HRestorePosition.
HDelete.
FOR EACH File.

These functions would read the current record from the file so they should set the ..new record property false.

Regards
Al




Edited 1 time(s). Last edit at 04/10/2009 09:29AM by Al.
Tavor
Re: ..NewRecord property not working?
April 10, 2009 09:51AM
Sorry. I typed wrong. When i use HReset ..NewRecord is true but when i use HReadSeekFirst it stays true (it should be false, but its not) and later i get error because i try to add record whit same unique key instead of modifying it.

When i need to add file i execute HReset(FILE) and when i need to modify it i execute HReadSeekFirst(FILE,FILE_ID,ID). HReadSeekFirst returns true but FILE..NewRecord remains true.


IF FILE..NewRecord = true THEN
HAdd(FILE)
ELSE
HModify(FILE)
END
Al
Re: ..NewRecord property not working?
April 10, 2009 11:37AM
Hello Tavor

I appreciate what you are saying about the accuracy of the ..NewRecord property, but regardless of it's status, your current process should be able to indicate if it is going to create a new record or edit an existing one, so the process sets the criteria for Hadd() or Hmodify(), not the ..NewRecordProperty.

Regards
Al
ICI
Re: ..NewRecord property not working?
April 13, 2009 09:33PM
Tavor !
IF I and other understand what you mean to say. You do not need to perform HreadSeek()
when you need to Hadd() or HModify() you just call it.

Example !
You have button for New record and when you press it your code is:
Hreset(YourFile)
Open(YourForm)
Tabledisplay(YourTable)

On "YourForm" On code for button click "Save" your code is:
ScreenToFile()
IF YourFile..NewRecord = True THEN
Hadd(YourFile)
ELSE
HModify(YourFile)
END
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: