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

Empty recordset: how to stop form from creating a new record? 1

Status
Not open for further replies.

irishandy

Programmer
Nov 18, 2003
39
IE
The same form is used for entering records, viewing records, editing records and deleting records. The user is also able to select various subsets of records by double-clicking on query names in a listbox.

I want to stop "ghost" records being created. At the moment if there is an empty recordset a new record is automatically created, i.e. the user sees a blank record. These records then linger in the main table and although they don't figure in overall calculations they are extremely annoying. I'm going to have to put in a procedure that will do a daily sweep of the table for these records and delete them.

There are a number of fields in the table that have default values, including the autonumber ID field.

Would anyone be able to suggest a solution to this problem?

 
In the On Close event of the form you might try using vb yes/no to ask if the current record should be saved and if not use Undo.


HTH

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
Autonumber Description - FAQ702-5106
 
Yes, but the problem is that the record has already been created therefore no matter if the user chooses yes or no the record will still remain. Ultimately the end user should not have to be concerned with these "ghost" records at all.
 
You may consider doing some checkings in the BeforeInsert event procedure of the form, setting Cancel to True if you discover that the current record is an empty one.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi!

You could try the before update event of the form. This event fires whenever an attempt to save the record is performed, and you can cancel it, or rather undo it. Test for values in controls you need values in, and perhaps also the .NewRecord property of the form.

But if these keep showing up without any control, do you assign values to some of the form controls programatically?

Roy-Vidar
 
Thanks for all the replies - it was the last line of that of RoyVidar that helped me see the light. The Current event of the form was calling various display functions however some of them were assigning values to bound as well as unbound fields. Hence a new record was being created each and every time. I went through the relevant modules line by line and amended them.

The problem is now fixed!

Thanks again, it really is much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top