On Exit in Subform Field

NathanSavidge

Registered User.
Local time
Today, 17:25
Joined
Apr 19, 2010
Messages
12
Hi,

I have a sub form, that has a control Volumes, which is where the user enters the volumes of a task they have done. When the exit this text box, if there is a value in the expected duration box, then it multiplies volumes by expected duration and places in total time. If not it will just go to total time for the user to add a time.

i.e. 100 at 5 mins each will auto populate 500 mins in TotalTime, if they have entered 100 where the expected duration is 0, then then they will be taken to Total Time box to add for themselves.

I have this code.

Private Sub intVolume_Exit(Cancel As Integer)
If Not (IsNull(Me.lng_Expected_Duration)) And Me.lng_Expected_Duration <> 0 Then
Me.intTotalTime = (Me.intVolume * Me.lng_Expected_Duration)
End If
End Sub

However, if i try to go from Volumes when the expected duration is populated to another row in the sub form, i cant do it until i go to another field (with no calculations in) on the same row, then i can move. It seems that until i go to the other control with no calcs, the total time calculation keeps happening.

Is there a way of allowing the exit to be selecting a field in another row of the sub form?

TIA

NATHAN.
 
Just stabbing here .... why not use your code on the AfterUpdate event of Me.intVolume and Me.lng_Expected_Duration?

In this manner, you're not dependant on moving records but only when either field is updated. Of course, you would probably need to use the Nz() function to wrap these in to avoid a null error for new records.

-dK
 

Users who are viewing this thread

Back
Top Bottom