Problem with report macro's using values in report

G

Guest

I am getting a strange error message in a couple of routines that I have in
my report. It says run time error 2427 and "You entered an expression that
has no value".
This is in the Report Open event and I tried putting it in the Report
Activate event because this occurs after Open.
I have an 'If' statement that checks the value of a textbox on the report.
The value shows on the report so it is there.
Whether the value is 5 or 7 determines which function to use to make a
calculation based on two other values in the report. Neither of these values
are available either if I put the 5 or 7 in to force the calculation.
I have other calculations ahead of these that work fine and are based on
hidden checkboxes where the the stored values -1 or 0 have to be displayed as
1, 0 or "" depending on certain conditions. These If's and calc's work great.
I'm sure there is a simple explanation but I can't figure out why these
three values aren't available to the VB routine and others in the same report
are. To make it even stranger it actually seemed to work a couple times
during troubleshooting but then wasn't permanent and never worked again.
 
A

Allen Browne

Wrong events.

Try using the Format event of the (Detail?) section, i.e. the section that
contains this text box.

You might be able to avoid the code by using IIf() in the ControlSource of
the text box, e.g.:
=IIf([Field1] = 1, Function1([Field1]), Func2([Field1]))
 
G

Guest

I put the code into the textbox. I actually originally had it in there
before I added the test for 5 or 7. It is selecting from two routines that
calculate a date based on whether it's a 5 or 7 day work week.
I thought the VB would be the best way and got caught up in trying to make
it work rather than revising what I originally had. Thanks for getting me
back on track and
Thanks once again.

Allen Browne said:
Wrong events.

Try using the Format event of the (Detail?) section, i.e. the section that
contains this text box.

You might be able to avoid the code by using IIf() in the ControlSource of
the text box, e.g.:
=IIf([Field1] = 1, Function1([Field1]), Func2([Field1]))

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rich J said:
I am getting a strange error message in a couple of routines that I have in
my report. It says run time error 2427 and "You entered an expression
that
has no value".
This is in the Report Open event and I tried putting it in the Report
Activate event because this occurs after Open.
I have an 'If' statement that checks the value of a textbox on the report.
The value shows on the report so it is there.
Whether the value is 5 or 7 determines which function to use to make a
calculation based on two other values in the report. Neither of these
values
are available either if I put the 5 or 7 in to force the calculation.
I have other calculations ahead of these that work fine and are based on
hidden checkboxes where the the stored values -1 or 0 have to be displayed
as
1, 0 or "" depending on certain conditions. These If's and calc's work
great.
I'm sure there is a simple explanation but I can't figure out why these
three values aren't available to the VB routine and others in the same
report
are. To make it even stranger it actually seemed to work a couple times
during troubleshooting but then wasn't permanent and never worked again.
 
G

Guest

I also tried using my VB code with the Format event of the Detail section and
that worked too. I'll keep that in mind for future. Nice to have options.

Allen Browne said:
Wrong events.

Try using the Format event of the (Detail?) section, i.e. the section that
contains this text box.

You might be able to avoid the code by using IIf() in the ControlSource of
the text box, e.g.:
=IIf([Field1] = 1, Function1([Field1]), Func2([Field1]))

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rich J said:
I am getting a strange error message in a couple of routines that I have in
my report. It says run time error 2427 and "You entered an expression
that
has no value".
This is in the Report Open event and I tried putting it in the Report
Activate event because this occurs after Open.
I have an 'If' statement that checks the value of a textbox on the report.
The value shows on the report so it is there.
Whether the value is 5 or 7 determines which function to use to make a
calculation based on two other values in the report. Neither of these
values
are available either if I put the 5 or 7 in to force the calculation.
I have other calculations ahead of these that work fine and are based on
hidden checkboxes where the the stored values -1 or 0 have to be displayed
as
1, 0 or "" depending on certain conditions. These If's and calc's work
great.
I'm sure there is a simple explanation but I can't figure out why these
three values aren't available to the VB routine and others in the same
report
are. To make it even stranger it actually seemed to work a couple times
during troubleshooting but then wasn't permanent and never worked again.
 

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