Duplicate field required, not functioning

N

NES

I know I'm going to hear that this is a bad design, but please bear with me.
I have a field in a sub form called Qty (quantity) that is saved to a detail
table. In addition, I need that same value saved to another "temporary" table
that is used for posting, and then cleared. I have the second Qty field
default set to = the value of the first Qty field. But no matter what I enter
into the first Qty field, the second one remains unchanged.

That is, if I set the first Qty field to default to a value on the primary
form, then both fields are set automatically to that value. But if I change
the first value to something else, the second one doesn't change.

If I leave the first Qty field without a default, (it goes to zero) then the
second Qty field also goes to zero, and remains at that value even when I
enter a value in the first Qty field. The posting table must me written when
the initial records are written. I can't see any way around it. So I need
this value. Short of double entry, is there any way around this problem?

Any help would be most appreciated. Thanks in advance.
 
M

Minton M

I know I'm going to hear that this is a bad design, but please bear with me.
I have a field in a sub form called Qty (quantity) that is saved to a detail
table. In addition, I need that same value saved to another "temporary" table
that is used for posting, and then cleared. I have the second Qty field
default set to = the value of the first Qty field. But no matter what I enter
into the first Qty field, the second one remains unchanged.

That is, if I set the first Qty field to default to a value on the primary
form, then both fields are set automatically to that value. But if I change
the first value to something else, the second one doesn't change.

If I leave the first Qty field without a default, (it goes to zero) then the
second Qty field also goes to zero, and remains at that value even when I
enter a value in the first Qty field. The posting table must me written when
the initial records are written. I can't see any way around it. So I need
this value. Short of double entry, is there any way around this problem?

Any help would be most appreciated. Thanks in advance.

How are you updating the second value? I would recommend setting some
code in the first control's AfterUpdate event, such as:

Private Sub Field1_AfterUpdate()
Field2.Value = Field1.Value
End Sub

.... which would ensure the second field is set. I'm a little unclear
from your posting how the two are linked programatically, but
hopefully this helps.

-- James
 
N

NES

Thank you James. The two are linked solely through the default property of
the second field (= [Qty dispensed]) I've tried to invoke the AfterUpdate
feature within the build function, but to no avail. I shall try your
suggestion now. Thanks again.
 
M

Minton M

Thank you James. The two are linked solely through the default property of
the second field (= [Qty dispensed]) I've tried to invoke the AfterUpdate
feature within the build function, but to no avail. I shall try your
suggestion now. Thanks again.
--
Norm Shimmel
Butler, PA

How are you updating the second value? I would recommend setting some
code in the first control's AfterUpdate event, such as:
Private Sub Field1_AfterUpdate()
Field2.Value = Field1.Value
End Sub
.... which would ensure the second field is set. I'm a little unclear
from your posting how the two are linked programatically, but
hopefully this helps.

Aha, that's why the second field is only picking up the initial value
of the first field. The default property is only triggered once so any
changes to field 1 will not publish through. Let me know how it goes!

-- James
 
N

NES

James, I suspected that was happening. But I still can't overcome it. I'm not
much into VBA code, and only rarely attempt anything with it. Often it fails,
but in this case I was totally in the dark. I'm assuming your suggestion
implied that the "AfterUpdate" code would be applied to the control rather
than to the continuous form. But I really don't know how to write the code.
When do you use underscores to separate tables and control names? I'm
comfortable with use of brackets, exclamation points and the. Is there a way
of doing this via the build function?

I appreciate your insight here. Thanks.
--
Norm Shimmel
Butler, PA


Minton M said:
Thank you James. The two are linked solely through the default property of
the second field (= [Qty dispensed]) I've tried to invoke the AfterUpdate
feature within the build function, but to no avail. I shall try your
suggestion now. Thanks again.
--
Norm Shimmel
Butler, PA

Minton M said:
I know I'm going to hear that this is a bad design, but please bear with me.
I have a field in a sub form called Qty (quantity) that is saved to a detail
table. In addition, I need that same value saved to another "temporary" table
that is used for posting, and then cleared. I have the second Qty field
default set to = the value of the first Qty field. But no matter what I enter
into the first Qty field, the second one remains unchanged.
That is, if I set the first Qty field to default to a value on the primary
form, then both fields are set automatically to that value. But if I change
the first value to something else, the second one doesn't change.
If I leave the first Qty field without a default, (it goes to zero) then the
second Qty field also goes to zero, and remains at that value even when I
enter a value in the first Qty field. The posting table must me written when
the initial records are written. I can't see any way around it. So I need
this value. Short of double entry, is there any way around this problem?
Any help would be most appreciated. Thanks in advance.
How are you updating the second value? I would recommend setting some
code in the first control's AfterUpdate event, such as:
Private Sub Field1_AfterUpdate()
Field2.Value = Field1.Value
End Sub
.... which would ensure the second field is set. I'm a little unclear
from your posting how the two are linked programatically, but
hopefully this helps.

Aha, that's why the second field is only picking up the initial value
of the first field. The default property is only triggered once so any
changes to field 1 will not publish through. Let me know how it goes!

-- James
 
N

NES

James, it took some tinkering to determine format, but I used your suggestion
to update a duplicate field and it works like a charm. Thank you so much for
your assistance. Much appreciated.
--
Norm Shimmel
Butler, PA


Minton M said:
Thank you James. The two are linked solely through the default property of
the second field (= [Qty dispensed]) I've tried to invoke the AfterUpdate
feature within the build function, but to no avail. I shall try your
suggestion now. Thanks again.
--
Norm Shimmel
Butler, PA

Minton M said:
I know I'm going to hear that this is a bad design, but please bear with me.
I have a field in a sub form called Qty (quantity) that is saved to a detail
table. In addition, I need that same value saved to another "temporary" table
that is used for posting, and then cleared. I have the second Qty field
default set to = the value of the first Qty field. But no matter what I enter
into the first Qty field, the second one remains unchanged.
That is, if I set the first Qty field to default to a value on the primary
form, then both fields are set automatically to that value. But if I change
the first value to something else, the second one doesn't change.
If I leave the first Qty field without a default, (it goes to zero) then the
second Qty field also goes to zero, and remains at that value even when I
enter a value in the first Qty field. The posting table must me written when
the initial records are written. I can't see any way around it. So I need
this value. Short of double entry, is there any way around this problem?
Any help would be most appreciated. Thanks in advance.
How are you updating the second value? I would recommend setting some
code in the first control's AfterUpdate event, such as:
Private Sub Field1_AfterUpdate()
Field2.Value = Field1.Value
End Sub
.... which would ensure the second field is set. I'm a little unclear
from your posting how the two are linked programatically, but
hopefully this helps.

Aha, that's why the second field is only picking up the initial value
of the first field. The default property is only triggered once so any
changes to field 1 will not publish through. Let me know how it goes!

-- James
 

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