Saving the value of a Calculated Text Box

J

Jaybird

This is not how a properly designed database is supposed to work, but our
database is sort of cobbled together and I'm kind of forced to go with the
flow. I have a main form frmInvoice. On it are two subforms, sbfInvoice and
sbfHDRPLAT. sbfInvoice is, as you might guess, a detail of the frmInvoice.
sbfHDRPLAT actually has a sub-subform called sbfLINPLAT that contains the
combobox [KEYNUM] and a textbox [LINETOTL]. Normally, the value of
[LINETOTL] is pretty straightforward, but when [KEYNUM] is equal to
"LINEITEM" I need the textbox [LINETOTL] to derive its value from a
calculation in sbfInvoice. The text box where this calculation takes place
is called txtTtlChrgs ([txtTtlChargs]=Sum([Charge])). The syntax of subform
references always throws me. Can anybody help point me in the right
direction? Corporate requires that this sum of charges be posted to our ERP,
so I'm kind of stuck. frmInvoice is designed to be an Invoice that
references Orders already in our database so that we don't have to use some
secondary or third party software.
 
J

Jaybird

I forgot to mention that the subform controls have the same names as the
subforms within them...
 
J

Jaybird

This might help as well... This is my code for the subform control
sbfLINPLAT in the On Current event:

Private Sub Form_Current()

If IsNull([KEYNUM]) Then Exit Sub
If [KEYNUM] = "SURCHGE" Then [ACCTLAB] = "SC"
[ACCTPRE] = 3052
If [KEYNUM] = "CERT" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
Me.LINETOTL = 10
If [KEYNUM] = "LINEITEM" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
Me.LINETOTL = Forms!frmInvoice!sbfInvoice.Form!txtTtlChrgs
If [KEYNUM] = "INSPECT" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
If [KEYNUM] = "STRAIGHT" Then [ACCTLAB] = "HT"
[ACCTPRE] = 3050
If [KEYNUM] = "AGING" Then [ACCTLAB] = "HT"
[ACCTPRE] = 3058
If [KEYNUM] = "OTHER" Then [ACCTLAB] = "OT"
[ACCTPRE] = 3510
If [KEYNUM] = "SOLUTION" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
If [KEYNUM] = "FREIGHT" Then [ACCTLAB] = "FR"
[ACCTPRE] = 3521

End Sub
--
Why are you asking me? I dont know what Im doing!

Jaybird


Jaybird said:
I forgot to mention that the subform controls have the same names as the
subforms within them...
--
Why are you asking me? I dont know what Im doing!

Jaybird


Jaybird said:
This is not how a properly designed database is supposed to work, but our
database is sort of cobbled together and I'm kind of forced to go with the
flow. I have a main form frmInvoice. On it are two subforms, sbfInvoice and
sbfHDRPLAT. sbfInvoice is, as you might guess, a detail of the frmInvoice.
sbfHDRPLAT actually has a sub-subform called sbfLINPLAT that contains the
combobox [KEYNUM] and a textbox [LINETOTL]. Normally, the value of
[LINETOTL] is pretty straightforward, but when [KEYNUM] is equal to
"LINEITEM" I need the textbox [LINETOTL] to derive its value from a
calculation in sbfInvoice. The text box where this calculation takes place
is called txtTtlChrgs ([txtTtlChargs]=Sum([Charge])). The syntax of subform
references always throws me. Can anybody help point me in the right
direction? Corporate requires that this sum of charges be posted to our ERP,
so I'm kind of stuck. frmInvoice is designed to be an Invoice that
references Orders already in our database so that we don't have to use some
secondary or third party software.
 
J

Jaybird

Upon further reflection, it occurs to me that the On Current event is not
where this should occur. However, I'm not sure where it should go. If I
feed the value of [LINETOTL] in the AfterUpdate event of [txtTtlChrgs] it
seems logical that I would get the most up to date information, since those
calculations take place after most other events. But, I can't seem to get it
to work.
--
Why are you asking me? I dont know what Im doing!

Jaybird


Jaybird said:
This might help as well... This is my code for the subform control
sbfLINPLAT in the On Current event:

Private Sub Form_Current()

If IsNull([KEYNUM]) Then Exit Sub
If [KEYNUM] = "SURCHGE" Then [ACCTLAB] = "SC"
[ACCTPRE] = 3052
If [KEYNUM] = "CERT" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
Me.LINETOTL = 10
If [KEYNUM] = "LINEITEM" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
Me.LINETOTL = Forms!frmInvoice!sbfInvoice.Form!txtTtlChrgs
If [KEYNUM] = "INSPECT" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
If [KEYNUM] = "STRAIGHT" Then [ACCTLAB] = "HT"
[ACCTPRE] = 3050
If [KEYNUM] = "AGING" Then [ACCTLAB] = "HT"
[ACCTPRE] = 3058
If [KEYNUM] = "OTHER" Then [ACCTLAB] = "OT"
[ACCTPRE] = 3510
If [KEYNUM] = "SOLUTION" Then [ACCTLAB] = "AL"
[ACCTPRE] = 3052
If [KEYNUM] = "FREIGHT" Then [ACCTLAB] = "FR"
[ACCTPRE] = 3521

End Sub
--
Why are you asking me? I dont know what Im doing!

Jaybird


Jaybird said:
I forgot to mention that the subform controls have the same names as the
subforms within them...
--
Why are you asking me? I dont know what Im doing!

Jaybird


Jaybird said:
This is not how a properly designed database is supposed to work, but our
database is sort of cobbled together and I'm kind of forced to go with the
flow. I have a main form frmInvoice. On it are two subforms, sbfInvoice and
sbfHDRPLAT. sbfInvoice is, as you might guess, a detail of the frmInvoice.
sbfHDRPLAT actually has a sub-subform called sbfLINPLAT that contains the
combobox [KEYNUM] and a textbox [LINETOTL]. Normally, the value of
[LINETOTL] is pretty straightforward, but when [KEYNUM] is equal to
"LINEITEM" I need the textbox [LINETOTL] to derive its value from a
calculation in sbfInvoice. The text box where this calculation takes place
is called txtTtlChrgs ([txtTtlChargs]=Sum([Charge])). The syntax of subform
references always throws me. Can anybody help point me in the right
direction? Corporate requires that this sum of charges be posted to our ERP,
so I'm kind of stuck. frmInvoice is designed to be an Invoice that
references Orders already in our database so that we don't have to use some
secondary or third party software.
 

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