98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Access VBA Training and help » Access VBA
Access VBA
Resolved · Low Priority · Version 2007
Louise has attended:
Access Advanced course
Access VBA course
Excel Pivot Tables course
Access VBA
I have inherited some VBA code and am trying to put it into 1 if statement (code below). Is this possible?
' change colour background on gad score 0
If Me.GAD71ScoreTotal = 0 Then
Me.GAD71Score0.BackColor = vbBlue
ElseIf Me.GAD71ScoreTotal = 1 Then
Me.GAD71Score0.BackColor = vbWhite
ElseIf Me.GAD71ScoreTotal = 2 Then
Me.GAD71Score0.BackColor = vbWhite
ElseIf Me.GAD71ScoreTotal = 3 Then
Me.GAD71Score0.BackColor = vbWhite
End If
'change colour background on gad score 1
If Me.GAD71ScoreTotal = 1 Then
Me.GAD71Score1.BackColor = vbBlue
ElseIf Me.GAD71ScoreTotal = 0 Then
Me.GAD71Score1.BackColor = vbWhite
ElseIf Me.GAD71ScoreTotal = 2 Then
Me.GAD71Score1.BackColor = vbWhite
ElseIf Me.GAD71ScoreTotal = 3 Then
Me.GAD71Score1.BackColor = vbWhite
End If
RE: Access VBA
Hi Louise, thanks for your query. I would use the Select Case expression to achieve this. More information here:
http://www.bettersolutions.com/vba/VNN529/LA011331611.htm
Hope this helps,
Anthony
Wed 6 Jun 2012: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Access tip:Remove spaces in a tableIf you have a table that has too many space marks littered around, you can create a update query and use the trim function to get rid of any excess space marks |