Return to field

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
 
D

Danny Seager

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

Sheila D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top