Focus Control

  • Thread starter Thread starter Frank Wagner
  • Start date Start date
F

Frank Wagner

The SetFocus method does not work when I try to bring the
focus back to the same control after an error condition.
My code is the following:

Private Sub A1_AfterUpdate()

Dim Answer As Long

Answer = Me.X1 * Me.Y1 'Calculate Answer

If Me.A1 <> Answer Then 'If answer not correct
Me.A1.ForeColor = 255 'Change Color To Red
Me.A1.SetFocus ' ???? Doesn't work ?????
Else
Me.A2.SetFocus ' Does work
End If

End Sub

I'm stuck. Any help would be appreciated

Frank Wagner
 
Does the ForeColor change?

What happens if you move the Me.A1.SetForeColor to after the
first SetFocus?

If in doubt whether the If Me.A1 <> Answer is firing put a
MsgBox in to check.

If Me.A1 <> Answer Then 'If answer not correct
Me.A1.SetFocus
Me.A1.ForeColor = 255 'Change Color To Red
MsgBox "Answer wrong triggered"
Else
Me.A2.SetFocus ' Does work
End If




--
Nick Coe (UK)
Available - Will work for money :-)
http://www.alphacos.co.uk/ AccHelp + pAnimal
http://www.pjandcoe.co.uk/ TShirts with Bark Factor!

In Frank Wagner typed:
 
Back
Top