Help needed Again!?

lizzieah

Registered User.
Local time
Tomorrow, 07:05
Joined
Mar 27, 2003
Messages
11
This site is so good. Glad to have help at my finger tips. All a learning process for me. Anyway
I actually got somewhere with some code,


Private Sub txtAcquisitionNo_BeforeUpdate(Cancel As Integer)

If Len(txtAcquisitionNo.Text) > 6 Then
MsgBox "Incorrect Length"
Cancel = vbCancel
End If
If IsNull(txtAcquisitionNo) Or (txtAcquisitionNo) = "" Then
MsgBox "Cant be Blank"
Cancel = vbCancel
End If
End Sub

Private Sub txtAcquisitionNo_Change()

If Len(txtAcquisitionNo.Text) > 6 Then
MsgBox "Incorrect Length"
End If

End Sub

BUT
Found out it only works after i type in a number and then delete it. I wont it to work so you cant move on to the next field until you have entered a number!

Thanks
 
Why do you have it on BeforeUpdate? What about on Exit. Then if the code will kick in if you try to you exit the field without having entered anything.
 
i have a form that only lets the user enter the next field
if all conditions that i have set are true
i dont know if there is a better way but this is what i do

declare a form module variable

dim GoBack as boolean
dim MyResponse as string
__________________________
sub CheckNumber
Goback=false

If Len(txtAcquisitionNo.Text) > 6 Then
Goback=true
Myresponse="Incorrect Length"
End If

If IsNull(txtAcquisitionNo) Or (txtAcquisitionNo) = "" Then
Goback=true
Myresponse="Cant be Blank"
End If

end sub
__________________________________
in the fields after your number field use the
on enter event
call CheckNumber
if goback=true then
msgbox Myresponse
exit sub
end if
also in the after update event for the same fields
if Goback=true then
me.txtAcquistionno.setfocus
exit sub
end if
 

Users who are viewing this thread

Back
Top Bottom