Full Version: Cycle Property
UtterAccess Forums > Microsoft® Access > Access Forms
I would like to set the 'cycle' property in a form via VBA. The form starts out as data entry, and works fine adding only one record at a time as needed, but when I close the form after the last record is added, then I get a blank record. I believe that if I could set the cycle property to "Current Record" or 1 just before the form closes, that would stop the additional blank record. Could someone help me in this regards?
Get a 'blank Record' where, exactly? If you add three Records, running the Form three times to do this, do you now have three 'blank' Records in the underlying Table?

Linq ;0)>
The Data Entry property means that the user sees only the records added since the user opened the form. Unless you have code in the Current or Before Insert event that writes a value to the record, the new record does not become a (mostly) blank record if the form is closed without entering other data. As an example of code writing a value, if you wish to insert the current date and time when a record is created you could set the Default Value of a field or control to Now(). The value will not be committed until the record is saved. If the record is not saved, it will remain a new record. On the other hand, if you have something like Me.ThisRecordDateTime = Now() in the Current or Before Insert event, a new record will be created unless there are required fields or otherwise the fields are validated.
I believe Bruce's analysis is correct here.

You're programmatically inserting a value somewhere in the form and that is causing a new "blank" record to be saved. I'd bet my best friend's motorcycle on it.
As long as the motorcycle belongs to your best friend!

I have a form that opens in Data Entry view. The Primary Key is an AutoNumber. The next field is the name of an organization, the next field is the contact's name. When I enter the organization and then the contact, then press the tab key, a new record is entered in the Organization Table. I can then enter a new organization and contact and add a new record when I tab out of the last field. When I, then, close the form, I get another record added to the table than is blank except for the autonumber. I'm doing nothing programmatically. At least not to my knowledge!

I realize that closing a form writes a record to the table. I don't want it to do that. I want to do data entry, then close the form without a record being added.

I hope I explained that okay. If not, I'll try again. I know what I'm doing and what my form and table are doing, but to explain that, sometimes eludes me.
"a new record is entered in the Organization Table"
When you open the table, is there a star (asterisk) to the left of the first column? If so, that means it is a new, unsaved record.

Tables should not be used for data entry, but it is possible. As soon as you start to enter a record into a table, Access provides a new row for the next record. Without that row there would be no place to enter a new record.
Hi Raas,

Pardon me for jumping in... I don't think the Cycle property will help in preventing these "new" records. Are you able to post some screenshots showing these new records? For example, missinglinq asked you earlier what happens if you open and close the form three times (entering one record each time), do you get three blank records at the end? If so, a screenshot of it would be nice.

Just a thought...
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.