Which sintaxe?

A

an

Hi!

I have a form based, in T_Subjects, with four fields:
Hour1, Subject1, Hour2, Subject2. (1st day and 2nd day)

In countinuous form I would like in textbox for Subject2, to make a
conditional format to change color where:

=If(Hour1=Hour2) And (Subject1=Subject2) And (Hour1=Hour2-00:30:00) Or
(Hour1=Hour2+00:30:00)

In spreadsheet work fine but in Access I don't know which the sintax.

I would like help for this.
Thanks in advance.
an
 
D

Douglas J. Steele

That's meaningless as a criteria. You're looking for those rows where Hour1
= Hour2 AND Hour1 = Hour2 - 30 minutes AND Hour1 = Hour2 + 30 minutes. No
record can possibly meet that criteria.

If what you want are all records where Subject1 equals Subject2 and Hour1 is
within 30 minutes either way of Hour2, try:

(Subject1=Subject2) And (Hour1 Between DateAdd("n", -30, Hour2) And
DateAdd("n", 30, Hour2))

If you're looking for something else, post back with more details.
 
A

an

Thanks you.
Sorry for my delay.

In Condition 1, Expression Is, in Conditional Formatting of the textbox Hour2:

("Subject1"="Subject2") And ("Hour1" Between DateAdd("n";-30;"Hour2") And
DateAdd("n";30;"Hour2"))

(1 - The quotations marks are of the Access2K
2 - ; and not , because is portuguese keyboard )

Thanks
an
 
A

an

Sorry.

In:

Condition 1
Field Value Is
equal to
("Subject1"="Subject2") And ...

Don't work too.

Thanks
an
 
D

Douglas J. Steele

Get rid of the quotes (except around "n" in the DateAdd function). That's
trying to compare the literal string "Subject1" to the literal string
"Subject2", which will, of course, always be false.

Try:

(Me.Subject1=Me.Subject2) And (Me.Hour1 Between DateAdd("n";-30;Me.Hour2)
And DateAdd("n";30;Me.Hour2))

I assume you're using a Regional Setting that uses semi-colons as
separators. If not, the DateAdd function should have commas, not
semi-colons.
 
A

an

Sorry, but don't change color when Hour1=Hour2 and Subject1=Subject2

With Expression Is or Field Value Is (?)

Thank you
an
 

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

Top