Autofill a check box based upon text field

G

Guest

I would like to be able to enter a year (i.e. "2004") in a form, check this
date against another date, and if the first date is less than the second,
check a check box automatically. I tried using this formula in the
expression builder but didn't work. I'm assuming it would be better to use
VB code but don't know enough about writing vitual basic:

=IIf([Deob Year]<Year([Month End Date]),[Include in Bookings
Report?]=0,[Include in Bookings Report?]=-1)

Any help would be appreciated. Thanks
 
G

Guest

I placed the code on the properties of a form field (bound to a table) as an
expression. The formula didn't give any errors but didn't have the expected
result either. I should be able to type in a year [Deob Year], see if it is
in the current year [Month End Date], and uncheck a box (or check it for that
matter) if it is not in the current year. I don't want an earlier year's
transaction to be included in the current year's totals so I am using this
check box to filter out anything prior to the current year. I just wanted to
automate it a bit by having Access check right after I typed the [Deob Year].
I figured I should use the "After Update" option. Any ideas?

German Saer said:
And where did you place this code? It may only need to be refreshed.

bondtk said:
I would like to be able to enter a year (i.e. "2004") in a form, check this
date against another date, and if the first date is less than the second,
check a check box automatically. I tried using this formula in the
expression builder but didn't work. I'm assuming it would be better to use
VB code but don't know enough about writing vitual basic:

=IIf([Deob Year]<Year([Month End Date]),[Include in Bookings
Report?]=0,[Include in Bookings Report?]=-1)

Any help would be appreciated. Thanks
 
G

German Saer

Why don't you better place this on the "BeforeUpdate" method in the form?

Me![Include in Bookings Report?]= ([Deob Year]<Year([Month End Date]))

if, of course, [Include in Bookings Report?] is the name of the control for
the checkbox.

Hope it helps.

--
___________
Thanks,

German Saer
Orlando, FL


bondtk said:
I placed the code on the properties of a form field (bound to a table) as an
expression. The formula didn't give any errors but didn't have the expected
result either. I should be able to type in a year [Deob Year], see if it is
in the current year [Month End Date], and uncheck a box (or check it for that
matter) if it is not in the current year. I don't want an earlier year's
transaction to be included in the current year's totals so I am using this
check box to filter out anything prior to the current year. I just wanted to
automate it a bit by having Access check right after I typed the [Deob Year].
I figured I should use the "After Update" option. Any ideas?

German Saer said:
And where did you place this code? It may only need to be refreshed.

bondtk said:
I would like to be able to enter a year (i.e. "2004") in a form, check this
date against another date, and if the first date is less than the second,
check a check box automatically. I tried using this formula in the
expression builder but didn't work. I'm assuming it would be better
to
use
VB code but don't know enough about writing vitual basic:

=IIf([Deob Year]<Year([Month End Date]),[Include in Bookings
Report?]=0,[Include in Bookings Report?]=-1)

Any help would be appreciated. Thanks
 
G

Guest

For some reason, this is not working. Once I type in the [Deob Year], the
check mark should either pop in (-1) or go away (0) if it is less than "2005"
(or Year([Month End Date]). Tried the code you gave me in the "BeforeUpdate"
of the [Deob Year] field & "BeforeUpdate" for the [Include in Bookings
Report?] field. Didn't know which field I should apply it to but didn't work
in either. Any other thoughts would be appreciated.

German Saer said:
Why don't you better place this on the "BeforeUpdate" method in the form?

Me![Include in Bookings Report?]= ([Deob Year]<Year([Month End Date]))

if, of course, [Include in Bookings Report?] is the name of the control for
the checkbox.

Hope it helps.

--
___________
Thanks,

German Saer
Orlando, FL


bondtk said:
I placed the code on the properties of a form field (bound to a table) as an
expression. The formula didn't give any errors but didn't have the expected
result either. I should be able to type in a year [Deob Year], see if it is
in the current year [Month End Date], and uncheck a box (or check it for that
matter) if it is not in the current year. I don't want an earlier year's
transaction to be included in the current year's totals so I am using this
check box to filter out anything prior to the current year. I just wanted to
automate it a bit by having Access check right after I typed the [Deob Year].
I figured I should use the "After Update" option. Any ideas?

German Saer said:
And where did you place this code? It may only need to be refreshed.

I would like to be able to enter a year (i.e. "2004") in a form, check
this
date against another date, and if the first date is less than the second,
check a check box automatically. I tried using this formula in the
expression builder but didn't work. I'm assuming it would be better to
use
VB code but don't know enough about writing vitual basic:

=IIf([Deob Year]<Year([Month End Date]),[Include in Bookings
Report?]=0,[Include in Bookings Report?]=-1)

Any help would be appreciated. Thanks
 

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