Label to show IF

B

Bob V

I want my label (Set to No Visible) to show on my form when I select a row
from my Combo Box ,if the date in the 5 Column is between 30 -60 days Old
the Name of the field in my Combo box is [MaxOfBillDate]
My Attempt:
Me.lblEmailAvailable.Visible = IIf(MaxOfBillDate 30 - 60
Days(Nz(Me.cbOwnerName.Column(4), 0)) _
And IsEmailOn, True, False)
Thanks if you can Help me.....................Bob
 
J

John W. Vinson

I want my label (Set to No Visible) to show on my form when I select a row
from my Combo Box ,if the date in the 5 Column is between 30 -60 days Old
the Name of the field in my Combo box is [MaxOfBillDate]
My Attempt:
Me.lblEmailAvailable.Visible = IIf(MaxOfBillDate 30 - 60
Days(Nz(Me.cbOwnerName.Column(4), 0)) _
And IsEmailOn, True, False)
Thanks if you can Help me.....................Bob

Well, that's imaginative code... not sure I understand it, and the VBA
compiler certainly will not!

The compiler has NO intelligence. It is a mindless text engine which only
recognizes valid expressions. Saying "MaxOfBillDate 30-60 Days" might make
sense to a human, but the poor compiler will be baffled!

Assuming that [MasOfBillDate] is a Date/Time field, try

Me.lblEmailAvailable.Visible = IIF(DateDiff("d", Nz(Me.cbOwnerName.Column(4),
Date())) , Date()) <= 60 AND DateDiff("d", Nz(Me.cbOwnerName.Column(4),
Date()), Date()) > 30 AND IsEmailOn, True, False)

The fieldname MaxOfBillDate isn't available within the combo box, you need to
extract the value directly; you might even need to wrap it in a CDate()
function.
 
B

Bob V

Oops Sorry John [MaxOfBillDate] is from a query that gives the last Date of
the table (Max), I am getting an error "Argument not Optional " on DateDiff!
Thanks for the help..Bob

John W. Vinson said:
I want my label (Set to No Visible) to show on my form when I select a row
from my Combo Box ,if the date in the 5 Column is between 30 -60 days Old
the Name of the field in my Combo box is [MaxOfBillDate]
My Attempt:
Me.lblEmailAvailable.Visible = IIf(MaxOfBillDate 30 - 60
Days(Nz(Me.cbOwnerName.Column(4), 0)) _
And IsEmailOn, True, False)
Thanks if you can Help me.....................Bob

Well, that's imaginative code... not sure I understand it, and the VBA
compiler certainly will not!

The compiler has NO intelligence. It is a mindless text engine which only
recognizes valid expressions. Saying "MaxOfBillDate 30-60 Days" might make
sense to a human, but the poor compiler will be baffled!

Assuming that [MasOfBillDate] is a Date/Time field, try

Me.lblEmailAvailable.Visible = IIF(DateDiff("d",
Nz(Me.cbOwnerName.Column(4),
Date())) , Date()) <= 60 AND DateDiff("d", Nz(Me.cbOwnerName.Column(4),
Date()), Date()) > 30 AND IsEmailOn, True, False)

The fieldname MaxOfBillDate isn't available within the combo box, you need
to
extract the value directly; you might even need to wrap it in a CDate()
function.
 
B

BruceM

I think there is one too many closing parentheses. There are three after
the first instance of Date. Try removing one, so that it matches the format
of the second DateDiff expression.

Bob V said:
Oops Sorry John [MaxOfBillDate] is from a query that gives the last Date
of the table (Max), I am getting an error "Argument not Optional " on
DateDiff!
Thanks for the help..Bob

John W. Vinson said:
I want my label (Set to No Visible) to show on my form when I select a
row
from my Combo Box ,if the date in the 5 Column is between 30 -60 days Old
the Name of the field in my Combo box is [MaxOfBillDate]
My Attempt:
Me.lblEmailAvailable.Visible = IIf(MaxOfBillDate 30 - 60
Days(Nz(Me.cbOwnerName.Column(4), 0)) _
And IsEmailOn, True, False)
Thanks if you can Help me.....................Bob

Well, that's imaginative code... not sure I understand it, and the VBA
compiler certainly will not!

The compiler has NO intelligence. It is a mindless text engine which only
recognizes valid expressions. Saying "MaxOfBillDate 30-60 Days" might
make
sense to a human, but the poor compiler will be baffled!

Assuming that [MasOfBillDate] is a Date/Time field, try

Me.lblEmailAvailable.Visible = IIF(DateDiff("d",
Nz(Me.cbOwnerName.Column(4),
Date())) , Date()) <= 60 AND DateDiff("d", Nz(Me.cbOwnerName.Column(4),
Date()), Date()) > 30 AND IsEmailOn, True, False)

The fieldname MaxOfBillDate isn't available within the combo box, you
need to
extract the value directly; you might even need to wrap it in a CDate()
function.
 
J

John W. Vinson

Oops Sorry John [MaxOfBillDate] is from a query that gives the last Date of
the table (Max), I am getting an error "Argument not Optional " on DateDiff!
Thanks for the help..Bob


Is [MaxOfBillDate] a field in the Form's recordsource query (in which case it
is available for your expression) or is it only in the Combo's recordsource
(in which case it isn't)?

The DateDiff expression might have unbalanced parentheses: let's see... yep,
missed one! Should be

Me.lblEmailAvailable.Visible = IIF(
DateDiff("d",
Nz(Me.cbOwnerName.Column(4), Date())) ,
Date())
<= 60
AND
DateDiff("d",
Nz(Me.cbOwnerName.Column(4), Date())),
Date())
 
B

Bob V

John it is just a row source from my query on my drop down combo box!
Thanks Bob
John W. Vinson said:
Oops Sorry John [MaxOfBillDate] is from a query that gives the last Date
of
the table (Max), I am getting an error "Argument not Optional " on
DateDiff!
Thanks for the help..Bob


Is [MaxOfBillDate] a field in the Form's recordsource query (in which case
it
is available for your expression) or is it only in the Combo's
recordsource
(in which case it isn't)?

The DateDiff expression might have unbalanced parentheses: let's see...
yep,
missed one! Should be

Me.lblEmailAvailable.Visible = IIF(
DateDiff("d",
Nz(Me.cbOwnerName.Column(4), Date())) ,
Date())
<= 60
AND
DateDiff("d",
Nz(Me.cbOwnerName.Column(4), Date())),
Date())
30 AND IsEmailOn, True, False)
 

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


Top