Return to field

  • Thread starter Thread starter Sheila D
  • Start date Start date
S

Sheila D

I'm trying to check that a value is not already in the table - this is what I
have put together so far using previous posts:
Private Sub Procedure_Number_AfterUpdate()
If (DLookup("[Procedure_Number]", "[T_Procedures]", "[Procedure_Number]=" &
Me.[Procedure_Number])) Then
MsgBox "procedure number exists"
Cancel = True
Me.Undo
Me.[Procedure_Number].SetFocus
End If
End Sub

I want the focus to return to the field if the procedure number already
exists but it's not happening - everything else seems to work OK so I'd be
most grateful for any help finishing this off. I don;t know much about vb so
please be gentle!
SSheila
 
move the checking to the before update event - then itshould never loose
focus so you won't need to set it's focus
 
Thanks Danny, works a dream

Danny Seager said:
move the checking to the before update event - then itshould never loose
focus so you won't need to set it's focus

Sheila D said:
I'm trying to check that a value is not already in the table - this is what I
have put together so far using previous posts:
Private Sub Procedure_Number_AfterUpdate()
If (DLookup("[Procedure_Number]", "[T_Procedures]", "[Procedure_Number]=" &
Me.[Procedure_Number])) Then
MsgBox "procedure number exists"
Cancel = True
Me.Undo
Me.[Procedure_Number].SetFocus
End If
End Sub

I want the focus to return to the field if the procedure number already
exists but it's not happening - everything else seems to work OK so I'd be
most grateful for any help finishing this off. I don;t know much about vb so
please be gentle!
SSheila
 
Back
Top