Save record containing only default value

  • Thread starter BruceM via AccessMonster.com
  • Start date
B

BruceM via AccessMonster.com

The real-world situation is that several documents may be sent for review at
the same time. The main record is a sort of umbrella record that contains
only the start date, the completion date, and a Yes/No field (the latter
actually Allen Browne's number field replacement for Yes/No fields). The
related subform records contain information about each of the documents to be
reviewed (one record per document). The main form's StartDate field defaults
to today's date. I typically move immediately to a subform to enter
information about each document to be reviewed. However, since the main form
was not dirtied, the main form record is not saved, and therefore the subform
records are not saved. If I enter a date in the main form all is well, but I
would like to use the default value for the StartDate field. BTW, the effect
is the same if I use the Default Value property of the text box bound to
StartDate rather than the table Default Value property.

The question is either how can I save a record that contains only a default
value, or how can I arrange things so that a value is placed in StartDate
when there are related subform records?

I can put this into the main form's Current event:

If Me.NewRecord Then
Me.StartDate = Date
End If

However, that means the record will be saved even if the user goes to a new
record, then reconsiders. I could have code to check whether there are
subform records, and to delete the main form record if there is not (by
running a Delete query, I suppose), but I can't help thinking I have
overlooked something simpler. The simplest, in a way, is not to use a
Default Value for Start Date, but rather have the user enter a date or click
a button, but the StartDate is almost invariably today, so I would rather
automate that part of it if I can. Also, I want to solve this problem on
general principles, as I expect I will learn something new.
 
B

BruceM via AccessMonster.com

Correction: the subform records are saved, but without the linking field, so
they are orphan records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top