Default value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I have a form with a date control which has as it's default value =Date().
How can I, using VBA, dirty the record using the default value if a user
enter a value in the subform without entering any other info in the main form?

Normally, the default value appears but doesn't get associated to the record
until another control is dirtied on the main form. So how can I dirty the
date control if my users go directly into the subform and make an entry?

(Using Access 2000)

Thank you for the help,

Daniel P
 
Daniel

I may be missing something...

In a typical main form/subform design, the main form holds "parent" record
data, while the subform holds "child" data record(s) related to the parent
record. Thus, it would be very unusual to go directly to a subform, since
there would be NO parent record it could relate to.

If you need to associate the current date (Date()) with each subform record,
you don't need a main form to do that. You could add a CurrentDate field to
the table underlying your subform and use a default-valued control in that
(sub)form. And you wouldn't need to embed it in a main form, so it would
become a (no-longer-sub)form in its own right.


--
More info, please ...

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
Daniel said:
I have a form with a date control which has as it's default value =Date().
How can I, using VBA, dirty the record using the default value if a user
enter a value in the subform without entering any other info in the main form?

Normally, the default value appears but doesn't get associated to the record
until another control is dirtied on the main form. So how can I dirty the
date control if my users go directly into the subform and make an entry?


It seems strange that you don't need any data in the main
form's new record before adding related records in the
subform. I would expect your question to be how to prevent
users from entering subform data until after meaninful data
has been entered in the main form new record.

With that said, you can dirty a record by assigning any
value to any bound control:
Me.someboundcontrol = somevalue
 
Normally I would agree. This is a very particular request where they wish to
be able to do mass processing when things are very busy and then come back
and fill in the missing data later. They normally would have had to enter
the date manually and this would have created the record instance so that
when they went on into the subform all would have been fine, but in my trying
to simplify their lives, I created a default value for the date they now jump
right into the subform and ... the question.

thank you so very much
 
Daniel said:
Normally I would agree. This is a very particular request where they wish to
be able to do mass processing when things are very busy and then come back
and fill in the missing data later. They normally would have had to enter
the date manually and this would have created the record instance so that
when they went on into the subform all would have been fine, but in my trying
to simplify their lives, I created a default value for the date they now jump
right into the subform and ... the question.


How is a parent record linked to its child records? Without
some data, it seems like the child records are not related
to anything. If the child records are linked to the main
record on the date field, then I suggest that you set the
date field's value instead of using the DefaultValue. (But,
that raises the question about what to do if no child
records are ever created.)
 
Back
Top