I am trying to get a query working that has two parameters. I can find a record in a table by using the ado recordset object with one parameter but I am unable to get it to work with two. I have a bridge table that I need to use two parameters to locate a unique row. The statement is as follows:
strSQL = "WHERE IncidentID_fk = " & Parm1 & " AND
GroupID_fk = " & Parm2
When I execute the code the compiler trips on the statement:
rst.Find strSql
the error message is:
Runtime error 3001
Arguments are of the wrong type,are out of acceptable range or are in conflict with one another.
If I shorten the query to the first parameter it executes fine.
The code:
Private Sub FindRecord(ByVal lngIncidentID As Long, ByVal lngGroupID As Long)
Dim lngParm1 As Long
Dim lngParm2 As Long
Dim intLoopctrl As Integer
lngParm1 = lngIncidentID
lngParm2 = lngGroupID
Dim rst As ADODB.Recordset
'lngIncidentID = 201
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open "Select * from
tblInc_bridge_ThreatLevBridge_Contact"
strSQL = "WHERE IncidentID_fk = " & Parm1 & " AND
GroupID_fk = " & Parm2
rst.Find strSQL
lngFoundRecord = rst!GroupID_fk
Debug.Print "Found Record May 17", lngFoundRecord
End Sub
Any help with this would be greatly appreciated.
Polnichek
strSQL = "WHERE IncidentID_fk = " & Parm1 & " AND
GroupID_fk = " & Parm2
When I execute the code the compiler trips on the statement:
rst.Find strSql
the error message is:
Runtime error 3001
Arguments are of the wrong type,are out of acceptable range or are in conflict with one another.
If I shorten the query to the first parameter it executes fine.
The code:
Private Sub FindRecord(ByVal lngIncidentID As Long, ByVal lngGroupID As Long)
Dim lngParm1 As Long
Dim lngParm2 As Long
Dim intLoopctrl As Integer
lngParm1 = lngIncidentID
lngParm2 = lngGroupID
Dim rst As ADODB.Recordset
'lngIncidentID = 201
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open "Select * from
tblInc_bridge_ThreatLevBridge_Contact"
strSQL = "WHERE IncidentID_fk = " & Parm1 & " AND
GroupID_fk = " & Parm2
rst.Find strSQL
lngFoundRecord = rst!GroupID_fk
Debug.Print "Found Record May 17", lngFoundRecord
End Sub
Any help with this would be greatly appreciated.
Polnichek