On one of my edit forms I have a combo box called EdSpID to select a certain financial source plus a text box EdSpAmount to record the amount. The idea is that if the user selects EdSpID=0, i.e. not relevant, EdSpAmount is disabled and if EdSpID>0, i.e. a source is selected, EdSpAmount is enabled and the focus moces to it. This is the code:
Private Sub EdSpID_AfterUpdate()
If Me!EdSpID = 0 Then
Me!EdSpAmount = 0
Me!EdSpAmount.Enabled = False
DoCmd.GoToControl “btnCancel”
Else
Me!EdSpAmount.Enabled = True
DoCmd.GoToControl “EdSpAmount”
End If
End Sub
When I select a source, EdSpID>0 but it fails on the line DoCmd.GoToControl “EdSpAmount” with a can’t move focus error. I can’t figure out why.