A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Return to field



 
 
Thread Tools Display Modes
  #1  
Old July 7th, 2008, 06:31 PM posted to microsoft.public.access.forms
Sheila D
external usenet poster
 
Posts: 211
Default Return to field

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
  #2  
Old July 7th, 2008, 08:31 PM posted to microsoft.public.access.forms
Danny Seager[_2_]
external usenet poster
 
Posts: 23
Default Return to field

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" wrote:

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

  #3  
Old July 7th, 2008, 09:34 PM posted to microsoft.public.access.forms
Sheila D
external usenet poster
 
Posts: 211
Default Return to field

Thanks Danny, works a dream

"Danny Seager" wrote:

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" wrote:

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.