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!

Converting DAO to ADO 1

Status
Not open for further replies.

Viruland

Programmer
Dec 6, 2000
61
BE
I've been changing my DAO to ADO and I have a problem with my Criteria. When I use only 1 criteria to find records in a recordset there is no problem, but when I use 2 or more citeria I've always error 3001 : Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Does somebody know what I'm doing wrong here.


Below is my function that I have written:

Public Function Check_Permission(TabelNr As Integer) As Integer

On Error GoTo Err_Check_Permission

Const conTableName as String = "Tbl_BevoegdheidFormulier"
Dim strPermCriteria As String
Dim rstPermRecord As New ADODB.Recordset

Set rstPermRecord = New ADODB.Recordset
strPermCriteria = "[TabelId] = " & TabelNr & " And [PersoneelsId] = " & intUserId
rstPermRecord.Open conTableName, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTable
rstPermRecord.Find strPermCriteria
If rstPermRecord.EOF Then
Select Case TabelNr
Case 11
strPermCriteria = "[TabelId] = " & TabelNr & " [GroepId] = " & bytGroep
Case 14
strPermCriteria = "[TabelId] = " & TabelNr & " And [GroepId] = " & bytGroep
End Select
rstPermRecord.Find (strPermCriteria)
If rstPermRecord.EOF Then
Check_Permission = 1
Else
Check_Permission = rstPermRecord!BevoegdheidId
End If
Else
Check_Permission = rstPermRecord!BevoegdheidId
End If

rstPermRecord.Close

Exit Function

Err_Check_Permission:
Call Display_Message(Err.Number & vbCrLf & Err.Description)

End Function
Live fast, die young and leave a beautiful corpse behind.
 
Don't know if this is your problem or not but you appear to be missing a concatenator for one of your criteria expressions:

Case 11
strPermCriteria = "[TabelId] = " & TabelNr & " [GroepId] = " & bytGroep

should be:

Case 11
strPermCriteria = "[TabelId] = " & TabelNr & " And [GroepId] = " & bytGroep

or it should be:

Case 11
strPermCriteria = "[TabelId] = " & TabelNr & " Or [GroepId] = " & bytGroep
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top