R
R Tanner
Hi,
I'm trying to run the following code whenever a user tries to create a
new record in the database. The purpose of this function is to check
for duplicates in the table. I am getting a runtime error 3001 with
the following description when I try to run the public function. Does
anyone have any idea why? I have done something similar to this in
the past, and didn't get any errors then.
Runtime Error 3001: Arguments Are Of The Wrong Type, Are Out Of The
Acceptable Range, or are in conflict with one another.
Public Function Duplicates() As Boolean
Dim RS As ADODB.Recordset
Dim DB As Database
Set DB = CurrentDb
Set RS = New ADODB.Recordset
Dim MyString As String
MyString = Forms![DocumentATicket]![Description]
With RS
.ActiveConnection = CurrentProject.Connection
.Open "SELECT Tickets.ID, Tickets.Description FROM Tickets", ,
adOpenDynamic, adLockOptimistic
.Find "Description = " & MyString
Select Case IsNull(.Fields(0))
Case True
Duplicates = False
Case False
Select Case .Fields(0)
Case Is = Forms![DocumentATicket]![ID]
Duplicates = False
Case Else
Duplicates = True
End Select
End Select
End With
DB.Close
RS.Close
Set DB = Nothing
Set RS = Nothing
End Function
I'm trying to run the following code whenever a user tries to create a
new record in the database. The purpose of this function is to check
for duplicates in the table. I am getting a runtime error 3001 with
the following description when I try to run the public function. Does
anyone have any idea why? I have done something similar to this in
the past, and didn't get any errors then.
Runtime Error 3001: Arguments Are Of The Wrong Type, Are Out Of The
Acceptable Range, or are in conflict with one another.
Public Function Duplicates() As Boolean
Dim RS As ADODB.Recordset
Dim DB As Database
Set DB = CurrentDb
Set RS = New ADODB.Recordset
Dim MyString As String
MyString = Forms![DocumentATicket]![Description]
With RS
.ActiveConnection = CurrentProject.Connection
.Open "SELECT Tickets.ID, Tickets.Description FROM Tickets", ,
adOpenDynamic, adLockOptimistic
.Find "Description = " & MyString
Select Case IsNull(.Fields(0))
Case True
Duplicates = False
Case False
Select Case .Fields(0)
Case Is = Forms![DocumentATicket]![ID]
Duplicates = False
Case Else
Duplicates = True
End Select
End Select
End With
DB.Close
RS.Close
Set DB = Nothing
Set RS = Nothing
End Function