VB code on a report problem

moulson

New member
Local time
Today, 18:59
Joined
Jul 17, 2000
Messages
6
[englishlet] has a value 1 or 0 if a pupils grade is between A* and C

I have the following code to create a running total on the footer of a report

If [recordcount] = 1 Then [englishlet] = 0 'resets values to 0
If [recordcount] = 1 Then [eng total] = 0 'resets values to 0

[englishlet] = 0
If [english grade] = "A*" Then [englishlet] = 1
If [english grade] = "A" Then [englishlet] = 1
If [english grade] = "B" Then [englishlet] = 1
If [english grade] = "C" Then [englishlet] = 1

If [englishlet] = 1 Then [eng total] = [eng total] + 1

[eng total] is displayed on the footer the problem is the number displayed from [eng total] is 1 more than it should be e.g. on the first page of the report I have 24 A*-C and the [eng total] displays 25. On the second page the total A*-C is now 45 but [eng total] displays 47. This happens on every page of the report except for the last one for some strange reason.

Where is the extra 1 coming from each time. I tried displaying the [eng total] next to each record on the report and the correct numbers are displayed down the first page but when it displays on the footer and extra 1 has been added.

I apologise in for my crude programming but I am new to VB.

Thanks Matt

[This message has been edited by moulson (edited 07-20-2000).]
 
This may have something to do with the * character, which is often treated as a wildcard, so it could be that ="A*" is finding both "A*" and "A". It's best to avoid using * in your data wherever possible, as its presence is difficult to test for.

This might work; change the first line of your IFs to:

If [english grade] = "A" & chr(42) Then [englishlet] = 1

or replace the whole block with:

If [english grade] >= "A" And [english grade] <= "C" Then [englishlet] = 1

let me know if it works (It might not be this at all, I'll keep thinking on it)

Mike
 

Users who are viewing this thread

Back
Top Bottom