Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with setfocus 1

Status
Not open for further replies.

Razor1

IS-IT--Management
Nov 21, 2002
81
US
It's Friday and I know my brain is already in weekend mode so please forgive me for this request for assistance.

I have a field on a form that data is scanned into and on exit I check to insure the scan is valid. If it is not valid then I want to clear the field and set the focus to that field to have the data rescanned.The cursor goes to the next field.

Any help is greatly appreciated.

The code is as follows.

Private Sub Chair_Exit(Cancel As Integer)
Dim lngRetval As Long
If Left(Forms!frm_RecordWork!Product, 2) <> "SH" Or Left(Forms!frm_RecordWork!Product, 2) <> "UC" Then
lngRetval = MsgBox( _
"Not a valid Product." & vbCrLf & "Rescan" & vbCrLf & "", _
vbOKOnly + vbExclamation + vbDefaultButton1, _
"Bad Scan")

Select Case lngRetval
Case vbOK
Me!Product.SetFocus

End Select
End If

End Sub


Razor1
 
Private Sub Product_Exit(Cancel As Integer)
If Left(Me!Product, 2) <> "SH" And Left(Me!Product, 2) <> "UC" Then
Cancel = True
End If
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks. I will have a much better weekend. You have a good weekend also.

Razor1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top