If Statement, What am I doing Wrong?

D

Dave Elliott

I am trying to check on a sub-form (Time and Hours) on my main form
(TimeCards) as to whether there are more than 2 hours or not on the sub-form
footer textbox Text95
The result I am getting is 2 times Text430 no matter what the hours are???
Why is this? What can I do to change it?
Thanks a Lot,

Dave


If Forms!TimeCards![Time and Hours].Form![Text95].Value < 2 Then
Rate = [Text430] * 2
End If
If Forms!TimeCards![Time and Hours].Form![Text95].Value >= 2 Then
Rate = [Text430]
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
 
P

Peter

I suggest you put a msgbox in to see the value you are testing:

Peter

msgbox "Value is: " & Forms!TimeCards![Time and
Hours].Form![Text95].Value
 
G

Guest

I agree with Peter, most like text95 is returning either null or empty value
which is therefore < 2.

Possibly your referencing one of the names of the controls wrong.

Is your sub-form control named Time and Hours or is that the name of the
form? I haven't tried it before but typically i do
forms("MainForm").controls("NameOfSubFormCONTROLnotFORM").controls("MyControl").value

Hope this helps.

Michael Proctor
NTDS
 

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

Similar Threads

Form refresh 2
DCount Expression Help Needed 2
Problem with Select 2
Value Equal Zero if Empty 1
New If Statement Post 24
DCount Expression needed for Formual? 1
Lookup Problem! 1
If Statement For Sub-Form 1

Top