Click here to Skip to main content
16,005,241 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub txtpid_LostFocus()
Dim flag As Boolean
Do While 2 > 0
For i = 1 To rec.RecordCount
If rec!pid = Val(txtpid.Text) Then
MsgBox ("pid already exists,enter again")
flag = True
Exit For
End If
Next i
If flag = True Then
txtpid.SetFocus
Else
Exit Do
endif
Loop
End Sub
Posted
Updated 21-Oct-12 20:39pm
v2
Comments
vivektiwari97701 22-Oct-12 2:31am    
can u explain a litile bit more and what error u r getting ????????
[no name] 22-Oct-12 2:41am    
hey now i am not getting any error..i have put an end if statement but still its not working...its not giving me msg on entering duplicate id's...

"But I am getting error in my code" - what does it mean? Why do you hide the error message from us? And the expect us to see the solution?
Well, I see that after "Exit Do" an "End If" is missing.
 
Share this answer
 
Comments
[no name] 22-Oct-12 2:36am    
yeah i am sorry the error was loop without do
Private Sub txtpid_LostFocus()
Dim flag As Boolean
Do While rec.EOF = False
If rec!pid = Val(txtpid.Text) Then
MsgBox ("pid already exists,enter again")
flag = True
End If
If flag = True Then
Exit Do
Else
rec.MoveNext
End If
Loop
If flag = True Then
txtpid.Text = ""
txtpid.SetFocus
End If
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900