subforms, textboxes, variables

Cereldine

Registered User.
Local time
Today, 00:12
Joined
Aug 4, 2005
Messages
71
hi, i have two continuous subforms on a main form. each of these subforms has a txtGrant textbox that totals up the values in the subform using a control source procedure.

on my main form i would like to add these two grant text boxes together using vba code. i can do it using the control source function, but feel if i do it in code then i can store the value as a global variable and thus use it somewhere else.

Should i do it this way or use the control source method? the code i have tried finds the value but is not passing the value to the variables, code below. why is this, it must be a simple error on my behalf!

Dim global_total As Double


Private Sub Form_Current()
Dim principle As Double
Dim provisional As Double
principle = (Nz(Me.sub_grant_calculation_form.Form!txtGrant))
provisional = (Nz(Me.sub_grant_provisional.Form!txtGrant))
global_total = principle + provisional
Me.txtTotalGrant.value = global_total
End Sub
 
try

principle = Me.sub_grant_calculation_form.Controls("txtGrant")
provisional = Me.sub_grant_provisional.Controls("txtGrant")
 

Users who are viewing this thread

Back
Top Bottom