Select Case using a variable through DIM

G

Guest

trying to use a Select Case statement for the following which uses a
variable, and it's not working??? thank you in advance!!



Dim INPLEDGE
INPLEDGE = ([First Contribution] + [Second Contribution] + [Contribution] +
Pledge)

Select Case True
Case INPLEDGE >= 25000
Forms![Form]![COMMITTEE LEVEL] = "BENEFACTOR"
Case INPLEDGE >= 10000 And INPLEDGE < 25000
Forms![Form]![COMMITTEE LEVEL] = "SPONSOR"
Case INPLEDGE >= 5000 And INPLEDGE < 10000
Forms![Form]![COMMITTEE LEVEL] = "PATRON"
Case INPLEDGE >= 1000 And INPLEDGE < 5000
Forms![Form]![COMMITTEE LEVEL] = "CHOICE"
Case INPLEDGE >= 500 And INPLEDGE < 1000
Forms![Form]![COMMITTEE LEVEL] = "SUPPORTER"

End Select
 
T

Tom Lake

trying to use a Select Case statement for the following which uses a
variable, and it's not working??? thank you in advance!!

Try this:
Dim INPLEDGE
INPLEDGE = ([First Contribution] + [Second Contribution] + [Contribution]
+
Pledge)

Select Case INPLEDGE
Case >= 25000
Forms![Form]![COMMITTEE LEVEL] = "BENEFACTOR"
Case 10000 To 24999.99
Forms![Form]![COMMITTEE LEVEL] = "SPONSOR"
Case 5000 To 9999.99
Forms![Form]![COMMITTEE LEVEL] = "PATRON"
Case 1000 To 4999.99
Forms![Form]![COMMITTEE LEVEL] = "CHOICE"
Case 500 To 999.99
Forms![Form]![COMMITTEE LEVEL] = "SUPPORTER"

End Select
 
D

Douglas J Steele

What are [First Contribution], [Second Contribution], [Contribution] and
Pledge? Is it possible that any of them are Null?

Use:

INPLEDGE = (Nz([First Contribution]) + Nz([Second Contribution]) +
Nz([Contribution]) + Nz(Pledge))
 
M

Marshall Barton

tgl said:
trying to use a Select Case statement for the following which uses a
variable, and it's not working???

Dim INPLEDGE
INPLEDGE = ([First Contribution] + [Second Contribution] + [Contribution] +
Pledge)

Select Case True
Case INPLEDGE >= 25000
Forms![Form]![COMMITTEE LEVEL] = "BENEFACTOR"
Case INPLEDGE >= 10000 And INPLEDGE < 25000
Forms![Form]![COMMITTEE LEVEL] = "SPONSOR"
Case INPLEDGE >= 5000 And INPLEDGE < 10000
Forms![Form]![COMMITTEE LEVEL] = "PATRON"
Case INPLEDGE >= 1000 And INPLEDGE < 5000
Forms![Form]![COMMITTEE LEVEL] = "CHOICE"
Case INPLEDGE >= 500 And INPLEDGE < 1000
Forms![Form]![COMMITTEE LEVEL] = "SUPPORTER"
End Select


Place a breakpoint on the Select Case line and investigate
the value of InPledge. I'll guess that it's Null (which
will happen if any of the values are Null). If that's
what's happening, change the expression to:

INPLEDGE = Nz([First Contribution], 0) _
+ Nz([Second Contribution], 0) _
+ Nz(Contribution, 0) _
+ Nz(Pledge, 0)
 

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