access vba

Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Access VBA

Access VBA

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Remove spaces in a table

If 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

View all Access hints and tips


Server loaded in 0.06 secs.