Run time Error 2427

G

Guest

"You entered an expression with no value"

The code that seems to be stumbling is:

Private Sub GroupFooter4_Format(Cancel As Integer, FormatCount As Integer)
If ([CtDetails] = 1) Then
Me.Line49.Visible = False
Else: Me.Line49.Visible = True
End If
If ([ctContr] = 1 And [CtDetails] = 1) Then
Me.Text102.Visible = False
Me.CalcTrade.Visible = False
Else: Me.Text102.Visible = True And Me.CalcTrade.Visible = True
End If

End Sub

The debugger tells me that the problem line is If ([CtDetails] = 1) Then

Assuming code gets executed top to bottom, I have other subroutines above
this which seem to be having no problems with this line of code. Does it
have to do with being in GroupFooter4?

The report opens with no error when I go to it and open it from the report
file. This problem only shows up when I open the report by pushing a button
on a form (which triggers some filtering).

Can anyone help me?

I am very new to VBA programming, but this should be very simple coding.

Thanks.
 
W

Wayne Morgan

Is there a chance that CtDetails can be Null? What happens if you use

If (Nz([CtDetails], 0) = 1) Then

Also, is there a textbox on the report that is bound to CtDetails? If not,
sometimes reports get picky and won't pick up a value from a field in its
Record Source unless that field is also bound to a control. If this is the
case, just set the Visible property of the control to No if you don't want
it to show.
Else: Me.Text102.Visible = True And Me.CalcTrade.Visible = True

I would also expect this statement to cause you a problem. The And should
make this a logical statement, not set the Visible of both controls. Try
this instead:

If ([ctContr] = 1 And [CtDetails] = 1) Then
Me.Text102.Visible = False
Me.CalcTrade.Visible = False
Else
Me.Text102.Visible = True
Me.CalcTrade.Visible = True
End If


--
Wayne Morgan
MS Access MVP


r. howell said:
"You entered an expression with no value"

The code that seems to be stumbling is:

Private Sub GroupFooter4_Format(Cancel As Integer, FormatCount As Integer)
If ([CtDetails] = 1) Then
Me.Line49.Visible = False
Else: Me.Line49.Visible = True
End If
If ([ctContr] = 1 And [CtDetails] = 1) Then
Me.Text102.Visible = False
Me.CalcTrade.Visible = False
Else: Me.Text102.Visible = True And Me.CalcTrade.Visible = True
End If

End Sub

The debugger tells me that the problem line is If ([CtDetails] = 1) Then

Assuming code gets executed top to bottom, I have other subroutines above
this which seem to be having no problems with this line of code. Does it
have to do with being in GroupFooter4?

The report opens with no error when I go to it and open it from the report
file. This problem only shows up when I open the report by pushing a
button
on a form (which triggers some filtering).

Can anyone help me?

I am very new to VBA programming, but this should be very simple coding.

Thanks.
 
G

Guest

It's still not working:

Wayne Morgan said:
Is there a chance that CtDetails can be Null? What happens if you use

If (Nz([CtDetails], 0) = 1) Then

It didn't like this any better.
Also, is there a textbox on the report that is bound to CtDetails? If not,
sometimes reports get picky and won't pick up a value from a field in its
Record Source unless that field is also bound to a control. If this is the
case, just set the Visible property of the control to No if you don't want
it to show.

There is a textbox which is named CtDetails and which is set as =Count(*) in
the report . This is in the groupHeader2 section. Is this my problem?
Else: Me.Text102.Visible = True And Me.CalcTrade.Visible = True

I would also expect this statement to cause you a problem. The And should
make this a logical statement, not set the Visible of both controls. Try
this instead:

If ([ctContr] = 1 And [CtDetails] = 1) Then
Me.Text102.Visible = False
Me.CalcTrade.Visible = False
Else
Me.Text102.Visible = True
Me.CalcTrade.Visible = True
End If

Thank you very much for this advice.

Any more ideas? Please?
 
W

Wayne Morgan

Try placing a textbox in the footer called (perhaps) CopyOfCtDetails, set
its Control Source to

=[CtDetails]

Then refer to this new textbox in your code. Also, have you verified what
value is actually in CtDetails when the report runs? If the textbox is a
hidden textbox, set it to be visible as a test to see what's in it. Also,
before the line in your code, place a Debug.Print statement to print the
value you're going to be using to the debug window and see what you get.

Example:
Debug.Print [CtDetails]
If ([CtDetails] = 1) Then
'etc

--
Wayne Morgan
MS Access MVP


r. howell said:
It's still not working:

Wayne Morgan said:
Is there a chance that CtDetails can be Null? What happens if you use

If (Nz([CtDetails], 0) = 1) Then

It didn't like this any better.
Also, is there a textbox on the report that is bound to CtDetails? If
not,
sometimes reports get picky and won't pick up a value from a field in its
Record Source unless that field is also bound to a control. If this is
the
case, just set the Visible property of the control to No if you don't
want
it to show.

There is a textbox which is named CtDetails and which is set as =Count(*)
in
the report . This is in the groupHeader2 section. Is this my problem?
Else: Me.Text102.Visible = True And Me.CalcTrade.Visible = True

I would also expect this statement to cause you a problem. The And should
make this a logical statement, not set the Visible of both controls. Try
this instead:

If ([ctContr] = 1 And [CtDetails] = 1) Then
Me.Text102.Visible = False
Me.CalcTrade.Visible = False
Else
Me.Text102.Visible = True
Me.CalcTrade.Visible = True
End If

Thank you very much for this advice.

Any more ideas? Please?
 
G

Guest

Thank you. the extra textbox did the trick. And I'll try the debug.print
trick just try to figure out what was happening--and to know for next time.

I do so much appreciate the time you and others put in to help folks like
me.


Wayne Morgan said:
Try placing a textbox in the footer called (perhaps) CopyOfCtDetails, set
its Control Source to

=[CtDetails]

Then refer to this new textbox in your code. Also, have you verified what
value is actually in CtDetails when the report runs? If the textbox is a
hidden textbox, set it to be visible as a test to see what's in it. Also,
before the line in your code, place a Debug.Print statement to print the
value you're going to be using to the debug window and see what you get.

Example:
Debug.Print [CtDetails]
If ([CtDetails] = 1) Then
'etc

--
Wayne Morgan
MS Access MVP


r. howell said:
It's still not working:

Wayne Morgan said:
Is there a chance that CtDetails can be Null? What happens if you use

If (Nz([CtDetails], 0) = 1) Then

It didn't like this any better.
Also, is there a textbox on the report that is bound to CtDetails? If
not,
sometimes reports get picky and won't pick up a value from a field in its
Record Source unless that field is also bound to a control. If this is
the
case, just set the Visible property of the control to No if you don't
want
it to show.

There is a textbox which is named CtDetails and which is set as =Count(*)
in
the report . This is in the groupHeader2 section. Is this my problem?
Else: Me.Text102.Visible = True And Me.CalcTrade.Visible = True

I would also expect this statement to cause you a problem. The And should
make this a logical statement, not set the Visible of both controls. Try
this instead:

If ([ctContr] = 1 And [CtDetails] = 1) Then
Me.Text102.Visible = False
Me.CalcTrade.Visible = False
Else
Me.Text102.Visible = True
Me.CalcTrade.Visible = True
End If

Thank you very much for this advice.

Any more ideas? Please?
 

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