Default value for each record.

J

Jack

I have a tabular form with Text Box FieldA, and Text Box
FieldB
FieldA is based on the field from the table.
I want the default value for the Unbouned Text Box FieldB
to be the same as FieldA.
I have set the Unbouned Text Box FieldB's default value to
=[FieldA]
If I change the value for FieldB in one record, all
records get the same value.
How to set up the default value based on each record?
Thanks
Jack
 
R

Rick Brandt

Jack said:
I have a tabular form with Text Box FieldA, and Text Box
FieldB
FieldA is based on the field from the table.
I want the default value for the Unbouned Text Box FieldB
to be the same as FieldA.
I have set the Unbouned Text Box FieldB's default value to
=[FieldA]
If I change the value for FieldB in one record, all
records get the same value.
How to set up the default value based on each record?

In a continuous or datasheet form only bound controls can show different
data per-row. You have to understand that you really only have ONE FieldB
TextBox. All of those iterations you see on the form are merely copies of
that one control. Whatever you put in that control is therefore shown on
all visible rows in the form.

You also have the wrong concept of a default value. Even if FieldB were a
bound TextBox you cannot set its default value to what will be entered in
FieldA because the default value is set as soon as the new record row is
instantiated. At that point FieldA does not yet have any value so neither
will FieldB.

You could use code in the AfterUpdate event of FieldA that would copy the
entry to FieldB, but again, as long as FieldB is unbound you would see that
value in every row of your form.

Perhaps if you explained what you are trying to accomplish we someone could
provide some alternative methods.
 
J

Jack

Hi, Rick

Thanks for your clear explanation.

I'm not adding new records into this form. This form is
only for updating existing records.
I'm creating a report that's based on FieldB.

I have created a new filed in the table, and bounded
FieldB to it.
Now, on the Form_Activate event, I would like to use the
For Each Record function, like this Me.FieldB = Me.FieldA

Am I doing the right ting?
If so, can you please tell me how do I use For Each
Function?
How to I reference each record

Thanks
Jack
-----Original Message-----
I have a tabular form with Text Box FieldA, and Text Box
FieldB
FieldA is based on the field from the table.
I want the default value for the Unbouned Text Box FieldB
to be the same as FieldA.
I have set the Unbouned Text Box FieldB's default value to
=[FieldA]
If I change the value for FieldB in one record, all
records get the same value.
How to set up the default value based on each record?

In a continuous or datasheet form only bound controls can show different
data per-row. You have to understand that you really only have ONE FieldB
TextBox. All of those iterations you see on the form are merely copies of
that one control. Whatever you put in that control is therefore shown on
all visible rows in the form.

You also have the wrong concept of a default value. Even if FieldB were a
bound TextBox you cannot set its default value to what will be entered in
FieldA because the default value is set as soon as the new record row is
instantiated. At that point FieldA does not yet have any value so neither
will FieldB.

You could use code in the AfterUpdate event of FieldA that would copy the
entry to FieldB, but again, as long as FieldB is unbound you would see that
value in every row of your form.

Perhaps if you explained what you are trying to accomplish we someone could
provide some alternative methods.


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.
 
R

Rick Brandt

Jack said:
Hi, Rick

Thanks for your clear explanation.

I'm not adding new records into this form. This form is
only for updating existing records.
I'm creating a report that's based on FieldB.

I have created a new filed in the table, and bounded
FieldB to it.
Now, on the Form_Activate event, I would like to use the
For Each Record function, like this Me.FieldB = Me.FieldA

Am I doing the right ting?
If so, can you please tell me how do I use For Each
Function?
How to I reference each record

I don't understand. If you're going to make your report based on FieldB and
you want to make FieldB equal to FieldA why don't you just use FieldA in
the first place?

One doesn't ordinarily even use a form if you want to automatically set the
value of a field in a bunch of records. You would just run an Update query
against the table itself.

UPDATE SomeTable SET FieldB = FieldA
 
J

Jack

Thanks again

Most of the records will not be changed.
About 20-30 out of 100 will be changed. So if the default
value = FiledA, I only have to change a few records.

Jack
 

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