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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datasheet Subform - return cursor to problem entry 1

Status
Not open for further replies.

crystalreporting

Instructor
Feb 13, 2003
649
NZ
Hi - I have a subform that is a datasheet for collecting serial numbers. I want to check that a serial number is entered, and that the serial number does not already exist. I have the following code in the 'After Update' event:

Private Sub Serial_Number_AfterUpdate()
Dim str_serial_number As String

If (IsNull(Me.Serial_Number)) Or Me.Serial_Number = "" Then
MsgBox "Must enter a valid serial number", vbInformation, "IM Enter Receipts"
Cancel = True
Me.Serial_Number.SetFocus
Exit Sub
End If

str_serial_number = Me.Serial_Number

If Not (IsNull(DLookup("[ser_lot_no]", "dbo_imlsmst_sql", "[ser_lot_no] = '" & str_serial_number & "'"))) Then
MsgBox "Serial number already exists", vbInformation, "IM Enter Receipts"
Cancel = True
Me.Serial_Number.SetFocus
Exit Sub
End If

End Sub

The problem is that after acknowledging the message, the cursor moves to the next line in the datasheet, instead of staying on the line with the problem. Any ideas?

Peter Shirley
 
If you want to have a Cancel argument then use the BeforeUpdate event !

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top