Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables in Access Reports

Status
Not open for further replies.

pd2222

Programmer
Oct 15, 2001
14
0
0
GB
Hi

I am trying to use a variable (= CC) in the following code in an Access Report, so that I can loop through 25 different CC's (only showing 3 here). However, it does not seem to like it. Could somebody please take a look at my code and see what I am doing wrong - maybe it can't be done but I need to know!!

CODE:

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)

Dim blnCCTotal As Boolean
Dim cc_num As Integer
Dim CC As Variant

For cc_num = 1 To 3
If cc_num = 1 Then
CC = "160001"
ElseIf cc_num = 2 Then
CC = "160002"
ElseIf cc_num = 3 Then
CC = "160003"
End If

'Determine whether the CCTotal has a value
blnCCTotal = IsNull([CC & ”Grand Total Sum”])

'Set the Visible property for the CC columns
[CC & “Label”].Visible = blnCCTotal
[CC].Visible = blnCCTotal
[“Sum of” & CC].Visible = blnCCTotal

Next cc_num

Thanks

Keza
 
It looks like your bracketing is wrong--you can't do
["xxx" & varable].property
inside brackets. Use this syntax:
me(CC & “Label”).Visible = true

Otherwise, what is the exact error you're getting?
--Jim
 
something else which looks a little incorrect is the CC variable. Are you trying to assign CC the value of 160003, or assign it a string containing this value? This will affect how the numbers are handled... James Goodman
 
Thank you Jim, it seems that the brackets were causing a problem which has now been resolved.

Keza

PS Thanks James for also replying!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top