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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple events using After Update

Status
Not open for further replies.

mraetrudeaujr

Technical User
Dec 20, 2004
137
0
0
US
This post relates to my previous post (thread702-1148781) where I needed to cause an 'option group' to return a YES or NO response depending on what value was selected in a combo box. I figured it out with the help of Xiciana, but now I've realized that this combo box should also trigger another 'option box' response, at the same time.

I have adjusted the table to include a fifth column with the appropriate information to 'call' from. So here is the previous code that is used on the "After Update" Event Procedure;

Code:
Private Sub cboCountryPage2_AfterUpdate()
    If Me.cboCountryPage2.Column(3) = 1 Then
    Me.optgrpSIRCountryPage2.Value = 1
Else
    Me.optgrpSIRCountryPage2.Value = 2
End If
    
End Sub

I thought that I could just add another 'If' statement directly below the "Me.optgrpSIRCountryPage2.Value = 1"
string; kind of like this;

Code:
Private Sub cboCountryPage2_AfterUpdate()
    If Me.cboCountryPage2.Column(3) = 1 Then
    Me.optgrpSIRCountryPage2.Value = 1
  Else
    Me.optgrpSIRCountryPage2.Value = 2
  End If
    If Me.cboCountryPage2.Column(4) = 1 Then
    Me.optgrpOtherThanMexicanPage4.Value = 1
  Else
    Me.optgrpOtherThanMexicanPage4.Value = 2
  End If
   
End Sub

However when I tested it, it performed the first operation, but didn't perform the second operation. What happened? I must be setting up the code out of order or wrong. Can anybody straighten out my code? Thank you.
 
Is it something to do with using Column(3) in the firest IF clause and Column(4) in the second ?

If the two columns are set to different values then you will get that effect.




G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
No, the values are the same (YES and NO responses...). Yes = 1 and No = 2.

The only difference is that column three is the "Special Interest Country" and column four is the "Other Than Mexican" response. This is why it is puzzling. I thought that if would simply be a change in the column number and (of course) the name of the Option Group that I would be using to record the information in the Main table.
 
Okay, I finally figured it out. Here is the final code...but with a problem at the end;
Code:
Private Sub cboCountryPage2_AfterUpdate()
  
  If Me.cboCountryPage2.Column(3) = 1 Then
     Me.optgrpSIRCountryPage2.Value = 1
  Else
     Me.optgrpSIRCountryPage2.Value = 2
End If
  
  If Me.cboCountryPage2.Column(4) = 1 Then
     Me.optgrpOTMpage4.Value = 1
  Else
     Me.optgrpOTMpage4.Value = 2
End If

  If Me.cboCountryPage2.Column(3) = 1 Then
     Me.optgrpSIRCountryPage2.BackColor = vbRed
  Else
     Me.optgrpSIRCountryPage2.BackColor = vbBlue
End If

End Sub

I want the background to change to "red" when this control is triggered as "YES". I've tried the '255' code and plain English "vbRed", but nothing happens. Any suggestions? The first two If statements work, but the last doesn't, why?
 
Well for a start your third If statement is the same as your first. So change it to

Code:
Private Sub cboCountryPage2_AfterUpdate()
  
If Me.cboCountryPage2.Column(3) = 1 Then
    Me.optgrpSIRCountryPage2.Value = 1
    Me.optgrpSIRCountryPage2.BackColor = vbRed
Else
    Me.optgrpSIRCountryPage2.Value = 2
    Me.optgrpSIRCountryPage2.BackColor = vbBlue
End If
  
If Me.cboCountryPage2.Column(4) = 1 Then
    Me.optgrpOTMpage4.Value = 1
Else
    Me.optgrpOTMpage4.Value = 2
End If

It will run much quicker.

Then look carefully at the BackStyle setting.
If it is set to Transaprent then it doesn't matter what you set the Colour to you will see right through it !


'ope-that-'elps.




G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top