Programming in a report

  • Thread starter dogbite via AccessMonster.com
  • Start date
D

dogbite via AccessMonster.com

On my report I have 2 boxes chk1 and pro1 also 2 lines line1 and line2.
Using Access2000
What I want to do in code is

Private Sub Form_Load()
If chk1.Text > 0 & pro1 < 0 Then
Line1.Visible = True & Line2.Visible = True
else chk1.Text > 0 & pro1.Text < 0 then
Line1.Visible = False & Line2.Visible = False
End If
End Sub

I hope that explaines it.
Thanks
 
J

J. Goddard

Actually, no - it doesn't.

Are talking about a form or a report?
Are chk1 and pro1 text boxes or check boxes?

Also, the two conditions of your If statement are identical - presumably
you want the lines visible if the conditions are true, and invisible
otherwise?

Can you clarify please?

John
 
A

Albert D. Kallal

reports are somewhat different then forms.

In reports, you need to place the code in the format event of the section in
question...

try moving the code to the particlar format event where those lines are
palced (heading, detail, etc).....
 
J

John Vinson

On my report I have 2 boxes chk1 and pro1 also 2 lines line1 and line2.
Using Access2000
What I want to do in code is

Private Sub Form_Load()
If chk1.Text > 0 & pro1 < 0 Then
Line1.Visible = True & Line2.Visible = True
else chk1.Text > 0 & pro1.Text < 0 then
Line1.Visible = False & Line2.Visible = False
End If
End Sub

I hope that explaines it.
Thanks

Well, it's pretty far from standard syntax. The & operator
concatenates strings; it does NOT let you put multiple statements on a
line nor is it the same as the logical operator AND. Also, a Report
does not have a Form_Load procedure.

If the report will be showing multiple records, some of which will
have different values for chk1 and pro1, you should use the Report's
Format event of the section containing these lines (which fires for
each page) rather than its Load event (which fires only once).
Something like:

Private Sub Detail_Format()
If Me.chk1 > 0 And Me.pro1 < 0 Then
Line1.Visible = True
Line2.Visible = True
Else
Line1.Visible = False
Line2.Visible = False
End If
End Sub


John W. Vinson[MVP]
 
D

dogbite via AccessMonster.com

John said:
On my report I have 2 boxes chk1 and pro1 also 2 lines line1 and line2.
Using Access2000
[quoted text clipped - 10 lines]
I hope that explaines it.
Thanks

Well, it's pretty far from standard syntax. The & operator
concatenates strings; it does NOT let you put multiple statements on a
line nor is it the same as the logical operator AND. Also, a Report
does not have a Form_Load procedure.

If the report will be showing multiple records, some of which will
have different values for chk1 and pro1, you should use the Report's
Format event of the section containing these lines (which fires for
each page) rather than its Load event (which fires only once).
Something like:

Private Sub Detail_Format()
If Me.chk1 > 0 And Me.pro1 < 0 Then
Line1.Visible = True
Line2.Visible = True
Else
Line1.Visible = False
Line2.Visible = False
End If
End Sub

John W. Vinson[MVP]



Thanks for everyones input I'll try this and see how it works
Thanks Lee
 
D

dogbite via AccessMonster.com

dogbite said:
[quoted text clipped - 24 lines]
John W. Vinson[MVP]

Thanks for everyones input I'll try this and see how it works
Thanks Lee
I have 10 boxes on my report and 16 lines. This is the code I came up with.
What I am trying to do is if 2 of the boxes are <> 0 then the proper lines
conect the 2 boxes and they are visible all other boxes and lines are not
visible. I havent had time to test it all yet but what little I did test
seemed to work. It seemes like there would be a better or shorter way of
doing it .
Ideas or suggestions or do ya think it will work or just trash it and use a
pen and draw my own lines?
Either way it'll be good for a LOL

Any how it wiggles nice when scrolled.
Thanks



If Me.txtCan1 <> 0 And Me.txtPed1 <> 0 Then
ln1.Visible = True
ln2.Visible = True
ln3.Visible = True
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = True
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = True
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = False

Else
If Me.txtCan1 <> 0 And txtPed2 <> 0 Then
ln1.Visible = True
ln2.Visible = True
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = True
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = True
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = False
Else
If Me.txtCan1 <> 0 And txtPed3 <> 0 Then
ln1.Visible = True
ln2.Visible = True
ln3.Visible = False
ln4.Visible = False
ln5.Visible = True
ln6.Visible = False
ln7.Visible = True
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = True
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = True
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = False
Else
If Me.txtCan2 <> 0 And txtPed1 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = True
ln4.Visible = True
ln5.Visible = True
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = True
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = False
Else
If Me.txtCan2 <> 0 And txtPed2 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = True
ln5.Visible = False
ln6.Visible = True
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = True
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = True
txtCan3.Visible = False
txtCan4.Visible = False
Else
If Me.txtCan2 <> 0 And txtPed3 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = True
ln5.Visible = False
ln6.Visible = False
ln7.Visible = True
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = True
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = True
txtCan3.Visible = False
txtCan4.Visible = False
Else
If Me.txtCan3 <> 0 And txtPed3 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = True
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = True
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = True
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = True
txtCan4.Visible = False
Else
If Me.txtCan3 <> 0 And txtPed4 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = True
ln9.Visible = True
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = True
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = True
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = True
txtCan4.Visible = False
Else
If Me.txtCan3 <> 0 And txtPed2 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = True
ln4.Visible = False
ln5.Visible = False
ln6.Visible = True
ln7.Visible = True
ln8.Visible = False
ln9.Visible = True
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = True
txtPed1.Visible = False
txtPed2.Visible = True
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = True
txtCan4.Visible = False
Else
If Me.txtCan3 <> 0 And txtPed5 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = True
ln11.Visible = True
ln12.Visible = False
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = True
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = True
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = True
txtCan4.Visible = False
Else
If Me.txtCan3 <> 0 And txtPed6 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = True
ln11.Visible = False
ln12.Visible = True
ln13.Visible = True
ln14.Visible = False
ln15.Visible = True
ln16.Visible = True
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = True
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = True
txtCan4.Visible = False
Else
If Me.txtCan4 <> 0 And txtPed5 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = True
ln12.Visible = True
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = True
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = True
Else
If Me.txtCan4 <> 0 And txtPed6 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = True
ln14.Visible = False
ln15.Visible = True
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = True
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = True
Else
If Me.txtCan4 <> 0 And txtPed2 <> 0 Then
ln1.Visible = False
ln2.Visible = True
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = False
ln10.Visible = False
ln11.Visible = False
ln12.Visible = False
ln13.Visible = True
ln14.Visible = True
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = True
txtPed3.Visible = False
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = True
Else
If Me.txtCan4 <> 0 And txtPed3 <> 0 Then
ln1.Visible = False
ln2.Visible = False
ln3.Visible = False
ln4.Visible = False
ln5.Visible = False
ln6.Visible = False
ln7.Visible = False
ln8.Visible = False
ln9.Visible = True
ln10.Visible = True
ln11.Visible = False
ln12.Visible = True
ln13.Visible = False
ln14.Visible = False
ln15.Visible = False
ln16.Visible = False
txtPed1.Visible = False
txtPed2.Visible = False
txtPed3.Visible = True
txtPed4.Visible = False
txtPed5.Visible = False
txtPed6.Visible = False
txtCan1.Visible = False
txtCan2.Visible = False
txtCan3.Visible = False
txtCan4.Visible = True


End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
 

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