Simple If...Then question

_Nickel_

Registered User.
Local time
Today, 23:40
Joined
Nov 11, 2003
Messages
31
I have a combo box in which you can choose the status of a task (not yet started, in progress, finished).
When the status is set to "finished" I want to insert a value that I calculated using a query into another field of the form (I want to use the BeforeUpdate event for this).
What I don't know is how I describe the field of the query that I want to get the value from in the following if...then statement:

If Status = "Finished" Then txtTimeTaken =

Thanks!
 
_Nickel_ said:
I want to insert a value that I calculated using a query

Can't you just calculate this at any time since you say you can already calculate it with a query?

I want to use the BeforeUpdate event for this

Which BeforeUpdate event; there's probably quite a few on your form? ;)
 
What I want insert is the time taken form for the task. The start time is set when the record is created and the end time is created when the status is set to finished. So I can only calculate the value after the status is changed. I walso want make it possible for the user to change the time taken.
I want to use the BeforeUpdate of the "status" combo box.

What I want to know is what I need to put after "=" in the statement above to get the value from the field "TimeTaken" from the query "qryTimeTaken".

thanks
 
If you are storing the TimeStarted then it makes more sense to store the TimeFinished - storing a calculated value within your table creates a violation of Third Normal Form (3NF) which states that you shouldn't store calculated values within a table; it creates a non-key dependency.

The value you want is always calculated within a query, report, or form at runtime.

And I'd use the AfterUpdate of the ComboBox:

Code:
Private Sub MyCombo_AfterUpdate()
    If Me.MyCombo = "Finished" Then Me.txtTimeFinished = Now()
End Sub
 
Mile-O-Phile said:
Code:
Private Sub MyCombo_AfterUpdate()
    If Me.MyCombo = "Finished" Then Me.txtTimeFinished = Now()
End Sub
[/B]

That is exactly what I am doing. I probably just explained it badly.
After thinking about it, I guess I should rather link my field to the query rather than store the calulated value like I initially wanted to do it. (I completely forgot about 3NF)
Thanks for pointing it out to me.
 

Users who are viewing this thread

Back
Top Bottom