If Statement Problem

  • Thread starter Thread starter ghost
  • Start date Start date
G

ghost

Greeting,
I have a text box called"FROM" with format Short time and there is an
unbound text box for showing Yes or No if FROM text box value is >= 13:00 and
I put the following code in On Open event of the form but the rsult is No:

Private Sub Form_Open(Cancel As Integer)
If Me.FROM.Value = "13:00" Then
Me.Text6 = "Yes"
Else
Me.Text6 = "No"
End If
End Sub
can any body help me please?
Note: there are more than 3 records have 13:00 and above
 
Hi Ghost,

the event on open is fired when you open the form so if the first record
fetched have from <13:00 then is normal that the field text6 is set to no and
it mantain this value 'cause the event doesn't fire again till the next time
you open the form.
If you wanna navigate through records and have the field updated put your
code in the on current event of your form.

HTH Paolo
 
Little addition to the previuos post

if you wanna set your field to yes if the from value is >= 13:00

If Me.FROM.Value >= #13:00# Then

Cheers
 
Thank you Paolo, but the problem as it is

I put the code on "On Current" but does not work
by the way, I put your code If Me.FROM.Value >= #13:00# Then
but access returen it to #1:00:00 PM#

Please advice?
 
The fact that access convert #13:00# to #1:00:00 PM# possibly means that you
have this setting in the regional setting for the hour format.
Anyway try in this way

If format(Me.FROM,"hh:mm:ss") >= #13:00:00# Then
Me.Text6 = "Yes"
Else
Me.Text6 = "No"
End If
 
Back
Top