Default Value Again

  • Thread starter Thread starter DSmith
  • Start date Start date
D

DSmith

I do have a problem--it only works on the current record in the form and not
for all the records. If I go to the next record it does not hold the default
for that record. I need for it to work on everyone's record.This is a form
with a subform and the field I want to use the code on is in the subform. So
do I need
to change the event from AfterUpdate to ?

Thanks in advance!
 
I do have a problem--it only works on the current record in the form and not
for all the records. If I go to the next record it does not hold the default
for that record. I need for it to work on everyone's record.This is a form
with a subform and the field I want to use the code on is in the subform. So
do I need
to change the event from AfterUpdate to ?

I guess I don't understand. Please post the actual VBA code you're
using; indicate the name of the control for which you wish to set the
default, the name of the main form, and the Name property of the
subform control containing the subform control which has the textbox
that you want to default.

John W. Vinson[MVP]
 
Okay, here is the code:
Private Sub Source_AfterUpdate()
Me!Source.DefaultValue = Chr(34) & Me!Source & Chr(34)
End Sub

Name of Main Form: Form_XRN TECH SUBSCRIPTIONS INPUT
Name of Subform: Form_XRN TECH SUBCRIPTIONS INPUT SUBFORM
Name of Text Box Control on subform: Source

The Main form gives me one record lets say Sam Jones. The Subform gives me
all of Sam Jone's subscriptions. The code works for Sam Jones but if I go to
Tom Smith in the main form the code does not work until I input it once and
then it works for Tom Smith. If I input in the source field of Sam Jones, it
becomes default for Sam Jones only, I'd like it to be default all the way
thru. If we do a mailing with the source code of "3/05" then most of our
subscriptions will come in with that source code. I like to be able to input
"3/05" in one record but have it be default for all records. The main form
come from a table named TECHS and the subform comes from a table named XRN
SUBSCRIPTIONS. I hope this is a satisfactory explanation.
 
Name of Main Form: Form_XRN TECH SUBSCRIPTIONS INPUT
Name of Subform: Form_XRN TECH SUBCRIPTIONS INPUT SUBFORM
Name of Text Box Control on subform: Source

The Main form gives me one record lets say Sam Jones. The Subform gives me
all of Sam Jone's subscriptions. The code works for Sam Jones but if I go to
Tom Smith in the main form the code does not work until I input it once and
then it works for Tom Smith. If I input in the source field of Sam Jones, it
becomes default for Sam Jones only, I'd like it to be default all the way
thru. If we do a mailing with the source code of "3/05" then most of our
subscriptions will come in with that source code. I like to be able to input
"3/05" in one record but have it be default for all records. The main form
come from a table named TECHS and the subform comes from a table named XRN
SUBSCRIPTIONS. I hope this is a satisfactory explanation.

I don't understand why moving to a different mainform record should
affect the DefaultValue property of a subform control; it doesn't in
my experience!

Is there a Source field on the mainform? or just on the subform?
What's the Master and Child Link Field of the subform?

John W. Vinson[MVP]
 
There is only a source field on the main form. The Master and Child link is
TechID. The main form is also linked to another main form thru a command
button that filters to a particular record but the form can be opened and
used on its own. I hope this helps. Is it possible to set this default up at
the table level? Thanks.
 
Sorry, I meant to say there is only a source field in the subform and NOT in
the main form.
 
Dear DSmith:

PMFJI...

Just a long shot... do you realize that the default value will only apply
when you create a *new* record? Are you perhaps under the impression that
this code will *update* existing records? If you wish to change the value in
one record, and then have that same change performed on all records which
already exist, then you would use an update query.

If this isn't applicable, please excuse the interruption!

HTH
Fred Boer
 
Thanks, yes I know, but that's not the case. This is in regards to a new
subscription record for each subscriber.
 
Hi
I don't know if that can help you

But I resolve the problem like that

If the field that you want to reset the default value is in the subform
there is different method do do it

In my case I had a field [Price] that have a defaultvalue set to 10$
Whith the time I realise that the default value should go to 15 $ so what i
did I
on the on doubleclick of the field [Price]

I wrote [Price].defaultvalue = Me![Price]

so when i doubleclick on the [Price] field of any record, the default value
change for that price
 
Back
Top