Populating field for each record

  • Thread starter Thread starter Nathan K via AccessMonster.com
  • Start date Start date
N

Nathan K via AccessMonster.com

Hey All

What I am trying to do is have a user type in a date in a field once and have
that date store automatically in a field on a subform. I would like this
date to remain the same in the subform even though a user may change records
in the main form.
My main form contains customer information that will stay the same. In the
subform I will want to store a record entered about the customer each week
(one-to-many). I am trying to make this as user friendly as possible so the
user will not have to type the same date everytime for each customer. I
can't set the default date to "NOW" because the records will not necessarily
be entered the day they occur. It does not matter to me if the field they
type the date in is on the main form or the subform as long as it is stored
in the subform.

I'm not much of a programmer, please be specific.
Any help would be appreciated
Thanks
Nathan
 
Nathan,
You could try using the AfterUpdate event of your DateField to ste th
DefaultValue for that field to the date that was just entered.

Private Sub YourDateField_AfterUpdate()
YourDateField.DefaultValue = "#" & YourDateField & "#"
End Sub

Any new subform records will be given that value, until you manually reneter
a new date. Then that new date becomes the Default.
 
Thanks Al
That worked perfectly

Al said:
Nathan,
You could try using the AfterUpdate event of your DateField to ste th
DefaultValue for that field to the date that was just entered.

Private Sub YourDateField_AfterUpdate()
YourDateField.DefaultValue = "#" & YourDateField & "#"
End Sub

Any new subform records will be given that value, until you manually reneter
a new date. Then that new date becomes the Default.
[quoted text clipped - 21 lines]
Thanks
Nathan
 
I there any way I can get that date to stay in in the field in the subform
even though I may switch records in my main customer form? That date only
stays in the subfom as long as I don't change mainform records. I will only
be entering one subfom record per mainform record at a time, but they will
all have the same date.

thanks
Nathan

Al said:
Nathan,
You could try using the AfterUpdate event of your DateField to ste th
DefaultValue for that field to the date that was just entered.

Private Sub YourDateField_AfterUpdate()
YourDateField.DefaultValue = "#" & YourDateField & "#"
End Sub

Any new subform records will be given that value, until you manually reneter
a new date. Then that new date becomes the Default.
[quoted text clipped - 21 lines]
Thanks
Nathan
 
Nathan,
That shouldn't happen. As long as you keep that form open, even moving
from main record to main record, the Default Value in the subform should
"hold".
If you close the form, that Default Value is lost.

I tested this using a subform where I entered "XX" as a State, and set
the Default to that value. As I browsed through several main records, the
default State value in the subforms remained "XX". This shouldn't be any
different than a Default date value.

I can only guess that you have some code that's causing the Default
value to be lost...
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Nathan K via AccessMonster.com said:
I there any way I can get that date to stay in in the field in the subform
even though I may switch records in my main customer form? That date only
stays in the subfom as long as I don't change mainform records. I will
only
be entering one subfom record per mainform record at a time, but they will
all have the same date.

thanks
Nathan

Al said:
Nathan,
You could try using the AfterUpdate event of your DateField to ste th
DefaultValue for that field to the date that was just entered.

Private Sub YourDateField_AfterUpdate()
YourDateField.DefaultValue = "#" & YourDateField & "#"
End Sub

Any new subform records will be given that value, until you manually
reneter
a new date. Then that new date becomes the Default.
[quoted text clipped - 21 lines]
Thanks
Nathan
 
I did have some bad code - Thanks for the reply
It works perfectly now.

Al said:
Nathan,
That shouldn't happen. As long as you keep that form open, even moving
from main record to main record, the Default Value in the subform should
"hold".
If you close the form, that Default Value is lost.

I tested this using a subform where I entered "XX" as a State, and set
the Default to that value. As I browsed through several main records, the
default State value in the subforms remained "XX". This shouldn't be any
different than a Default date value.

I can only guess that you have some code that's causing the Default
value to be lost...
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
I there any way I can get that date to stay in in the field in the subform
even though I may switch records in my main customer form? That date only
[quoted text clipped - 22 lines]
 
Back
Top