Here is how its supposed to work but the VBA is messed up.
I enter a number into txtMinutes and that number is suposed to be subtracted
from the number already in txtAccTimeWorked and then give the total in
another text box named txtDTRegular.
Private Sub txtMinutes_AfterUpdate()
Me.txtDTRegular = (Round(Me.txtMinutes / 60, 2) - Me.txtAccTimeWorked)
Forms!frmMainDB!txtMinutes = Me.txtDTRegular
End Sub
You don't need to assign the value to txtDTRegular unless you want to be able
to edit the value assigned. You can make the ControlSource of txtDTRegular:
= Me.txtAccTimeWorked – Round(Nz(Me.txtMinutes,0) / 60, 2)
In this scenario you should not be storing the value in txtDTRegular in a
column in the underlying table, but only the values of txtAccTimeWorked and
txtMinutes, which should be bound controls, as the value of txtDTRegular is
computed from these.
If you do want to be able to edit the value of txtDTRegular then assign it
in the txtMinutes control's Afterupdate event procedure using the same
expression. In this scenario all three text boxes would be bound controls
and you'd need three columns in the table.
What is the following meant to do?
Forms!frmMainDB!txtMinutes = Me.txtDTRegular
At first sight it seems to be assigning the computed value back to
txtMinutes, which does not seem very logical.
Ken Sheridan
Stafford, England
> Here is how its supposed to work but the VBA is messed up.
> I enter a number into txtMinutes and that number is suposed to be subtracted
[quoted text clipped - 5 lines]
> Forms!frmMainDB!txtMinutes = Me.txtDTRegular
> End Sub
Chad - 11 Jan 2008 23:03 GMT
Ken, I have this posted at Access Forum as well as here so I can upload a
test file so people to look at. You could understand my post better if you
see the test DB, the post and DB are here....
http://www.access-programmers.co.uk/forums/showthread.php?t=141599

Signature
Newbies need extra loven.........
> You don't need to assign the value to txtDTRegular unless you want to be able
> to edit the value assigned. You can make the ControlSource of txtDTRegular:
[quoted text clipped - 30 lines]
> > Forms!frmMainDB!txtMinutes = Me.txtDTRegular
> > End Sub
Ken Sheridan - 12 Jan 2008 00:01 GMT
In your form the AfterUpdate event procedure of the Text2 control would
contain the following code:
txtDTRegular = Round((Text2 / 60) - (txtEmployeeTime - txtDTReason1), 2)
But first you need to change the data types of the three columns (apart from
the ID column) in the table to single precision floating point numbers. At
present they are long integers so the delay result will be rounded to the
nearest hour.
I still feel you'd be better storing values *entered* in the form and
computing the delay, however.
Ken Sheridan
Stafford, England
> Ken, I have this posted at Access Forum as well as here so I can upload a
> test file so people to look at. You could understand my post better if you
[quoted text clipped - 35 lines]
> > > Forms!frmMainDB!txtMinutes = Me.txtDTRegular
> > > End Sub
Chad - 12 Jan 2008 02:01 GMT
Ken thanks, It works but its giving me an negative number? Like if my ending
result was .33 it would show -.33? Thanks! Also what do you mean by saving?
Could you explain since you think it is a better solution I might want to go
with it......

Signature
Newbies need extra loven.........
> In your form the AfterUpdate event procedure of the Text2 control would
> contain the following code:
[quoted text clipped - 51 lines]
> > > > Forms!frmMainDB!txtMinutes = Me.txtDTRegular
> > > > End Sub
Chad - 12 Jan 2008 14:25 GMT
Ken, I got the minus symbol. I used this formula instead and it works great!
Thanks for all your help...
Me.txtDTRegular = Round((txtAccTimeWorked) - (txtMinutes / 60), 2)