View Single Post
  #5 (permalink)  
Old 05-05-2008, 03:12 PM
agraham's Avatar
agraham agraham is offline
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,944
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

It works fine for me if you move the button enabling/disabling code after the radio button setting but I'm not sure why.

Code:
Sub ShowData
    Label1.Text=
"Q"&(AnsRec+1)&""
    
If Answer(AnsRec)=0 Then
        
For i=1 To 5
            Control(
"RadioBtn"&i).Checked=False
        
Next
    
Else
        Control(
"RadioBtn"&Answer(AnsRec)).Checked=True
    
End If
    
If AnsRec=0 Then
        PrevBtn.Enabled=
False
        NextBtn.Enabled=
True
    
Else If AnsRec=5 Then
        PrevBtn.Enabled=
True
        NextBtn.Enabled=
False
    
Else
        PrevBtn.Enabled=
True
        NextBtn.Enabled=
True
    
End If    
End Sub
EDIT : Got it! I didn't originally get the full import of Erel's explanation. Disabling the Prev button causes the focus to move from the Prev button back to the Radio Button. However AnsRec has already been decremented so Radio_Click thinks this extra click it is a new value for Q1 and stores what was the value for Q2 as Q1's value overwriting the previous value. Putting the disabling later ensures that the correct Radio Button for Q1 has already been selected so that it still overwrites the answer, but with the correct one this time!

Last edited by agraham : 05-05-2008 at 03:38 PM.
Reply With Quote