Jump to content

Deleting record with no content


This topic is 7805 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I now click on a button in one db to log a phone call in another db. This button click creates and new record, which contains a field called "call log." If I leave that screen/db without entering any text in the call log field, I would like to have that new record deleted automatically. How do I do this?

thanks,

Harry

Link to comment
Share on other sites

Here's one way...

You would have to actually do something to initiate the script which deletes empty records.

If you open the database often (daily) then you could set this as a script which runs whenever the database opens.

The script would perform a find for "=" in the call log field, then delete found records. If you want to be sure that there's nothing in any fields, just put ='s in each of the fields and the find will only find records where all are blank

Here's another way I just thought of...

Don't create a new record, just take them to a layout with global fields on it. In this case, the user MUST actually "Save" the record by activating a script which creates a new record and copies the global fields into the real fields. The risk is that the user will enter information, forget to save, and then quit the database.

Link to comment
Share on other sites

The best way to manage this problem is to use a relationship based system which avoids the creation of empty records in the first place.

To do this, create a global number field called 'gCurrentLogSerial' in your main db and define a new relationship called 'LogEntry' from your main db to the logs db which matches the new global field with a serial number field in your related db. Make sure that 'Allow creation of related records' is turned on for the 'LogEntry' relationship.

Also create relationship to your log file based on a calculating constant field (ie one with the formula set to 1) in both files, called 'LogsGlobal'

Next modify your new record script so that it has a single step, as follows:

Set Field ["gCurrentLogSerial", "Max(LogsGlobal::LogSerial#) + 1"]

Finally, make sure that the fields on your layout for entering log data into are accessed via the LogEntry relationship.

Then when you click the new log record button, it will prime the relationship ready for a new record to be created, but the actual record creation will not occur until you enter some data into one of the fields.

This approach will work seamlessly, creating new records whenever they are required, but never producing any empty records.

In addition, if you want to also be able to navigate backwards and forwards viewing the previous log entries in the fields on your main file layout, you could do so by providing back and forward buttons with script attached with the following steps in each respectivly:

Forward script:

Set Field ["gCurrentLogSerial", "Case(gCurrentLogSerial => Max(LogsGlobal::LogSerial#, Max(LogsGlobal::LogSerial#,), gCurrentLogSerial + 1"]

Back script:

Set Field ["gCurrentLogSerial", "Case(gCurrentLogSerial =< Min(LogsGlobal::LogSerial#, Min(LogsGlobal::LogSerial#,), gCurrentLogSerial - 1"]

- or alternatively, you could display the existing log records in a scrolling list in a portal based on the LogsGlobal relationship.

Link to comment
Share on other sites

Thanks much -- this one worked. Simply find all records with empty fields -- search using '=' in field. Then Delete All Records -- deletes those found records only. Make a script with those 2 items and run them upon opening or closing db.

thanks again,

Harry

Link to comment
Share on other sites

This topic is 7805 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.