I have a form that attempts to do a "driver" lookup, based on a Driver ID. I have an After-update procedure, with the code listed below. The problem I have is that after entering a value in the Driver ID field, I get a Run-time error 3251. Any suggestions? Thanks.
Private Sub DriverID_AfterUpdate()
'Declare DAO object variables
Dim ThisDB As Database
Dim DrvList As Recordset
Dim LookFor As String
If IsNull(Me!DriverID) Then
Exit Sub
End If
'If not blank, look it up.
Set ThisDB = CurrentDb()
Set DrvList = ThisDB.OpenRecordset("Employee/Drivers")
DrvList.Index = "PrimaryKey"
LookFor = Me![DriverID]
DrvList.Seek "=", LookFor
If DrvList.NoMatch Then
Beep
Else
Me![DriverName] = [DrvList]![Last]
End If
[DrvList].Close
End Sub
Private Sub DriverID_AfterUpdate()
'Declare DAO object variables
Dim ThisDB As Database
Dim DrvList As Recordset
Dim LookFor As String
If IsNull(Me!DriverID) Then
Exit Sub
End If
'If not blank, look it up.
Set ThisDB = CurrentDb()
Set DrvList = ThisDB.OpenRecordset("Employee/Drivers")
DrvList.Index = "PrimaryKey"
LookFor = Me![DriverID]
DrvList.Seek "=", LookFor
If DrvList.NoMatch Then
Beep
Else
Me![DriverName] = [DrvList]![Last]
End If
[DrvList].Close
End Sub