By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,437 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Set Control Source based on day of month (1st through 31st)

P: n/a
For a field on a report, I'm trying to use an If/Then statement to set
the Control Source depending on the day of the month. I need one
Control Source for days 1-14 and another for 15-31. To do this I put
this into the report's open event:
If (Day(date) < 15) Then
here are the control source statements and the Else statement.
End If

On one report this works fine, but after I copy and paste the code into
another report, when I try to open the report it gives the error:
Runtime Error 2427
You entered an expression that has no value.
After I click the debug button, it highlights the If/Then line:
If (Day(date) < 15) Then

I tried setting the problem report to the same query that the other
report uses (they have many of the same fields and their queries are
very similar) but it still gives the error. I made sure that I'm
putting it into the report's Open section. For testing, I tried
disabling the controlsource setting line and just using a command that
changes the fore color, but same results.

**The word "date" in the If/Then line above is not a field on the
report, it's the Access variable for the date. I tried to make the line
say:
If (Day(date()) < 15) Then
but as soon as my cursor leaves the line it changes back to this:
If (Day(date) < 15) Then

Anyone know what would be causing this?

Aug 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I got this fixed several days ago and I believe that the problem was
that the If/Then statement was used for field formatting and field
enabling/disabling statements. I moved the whole bunch from the Report
Open section to the Detail Format section and it started working.

Aug 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.