Run-time error 3251

alpine82

Registered User.
Local time
Today, 08:28
Joined
Jun 5, 2003
Messages
27
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
 
Is the driver list in a table? If so create a form with the driver list as the record source and use the access wizard to create a combo box or list box. You will be able to adapt the code to siut your needs.
 
This code has been generated by the wizard:

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ProcedureID] = " & Str(Me![List15])
Me.Bookmark = rs.Bookmark

HTH
Dave
 
Thanks!

Thanks, the combo box approach seems to work; now I'll just play with the code.
 

Users who are viewing this thread

Back
Top Bottom