N
Niklas Östergren
Hi!
I´m quit new to ADO and I try to make a validation (see below) to see if I
find the record selected (with Seek method) but my validation doesn´t work.
I get runtime error 3021 ("Valid record missing", or something like that in
english). Which is correct sinse the record doesn´t yet exist in the
recordset.
IsNull is obvoiusly not a good aproach to validate Seek-method. But what
should I use instead?
TIA!
// Niklas
Her´s the validation I can´t get to work.
=========================================================
If IsNull("rec.Seek " = ", strSearchString") Then
Exit Function
Else
rec.Seek "=", strSearchString
' If value <> 0 send value to calling sub else exit function
If rec("Value") <> 0 Then
SeekStoredCriteria = rec("Value")
Else
Exit Function
End If
End If
=================================================================
Her´s the whole code for this simple function:
=================================================================
Function SeekStoredCriteria(strSQL As String, strSearchString As String) As
Integer
Dim db As Database
Dim rec As Recordset
Dim strMsg As String
'Check validity of passed parameters.
' Exit sub presenting Msg if not valid
If IsNull("strSQL") Or strSQL = "" Or IsNull("strSearchString") Or
strSearchString = "" Then
strMsg = "SQL-string and/or string to search for is missing."
MsgBox strMsg
Exit Function
Else
Set db = Currentdb()
Set rec = db.OpenRecordset(strSQL)
rec.Index = "PrimaryKey"
' If strSearchString doesn´t exist exit function else get value
If IsNull("rec.Seek " = ", strSearchString") Then
Exit Function
Else
rec.Seek "=", strSearchString
' If value <> 0 send value to calling sub else exit function
If rec("Value") <> 0 Then
SeekStoredCriteria = rec("Value")
Else
Exit Function
End If
End If
End If
End Function
I´m quit new to ADO and I try to make a validation (see below) to see if I
find the record selected (with Seek method) but my validation doesn´t work.
I get runtime error 3021 ("Valid record missing", or something like that in
english). Which is correct sinse the record doesn´t yet exist in the
recordset.
IsNull is obvoiusly not a good aproach to validate Seek-method. But what
should I use instead?
TIA!
// Niklas
Her´s the validation I can´t get to work.
=========================================================
If IsNull("rec.Seek " = ", strSearchString") Then
Exit Function
Else
rec.Seek "=", strSearchString
' If value <> 0 send value to calling sub else exit function
If rec("Value") <> 0 Then
SeekStoredCriteria = rec("Value")
Else
Exit Function
End If
End If
=================================================================
Her´s the whole code for this simple function:
=================================================================
Function SeekStoredCriteria(strSQL As String, strSearchString As String) As
Integer
Dim db As Database
Dim rec As Recordset
Dim strMsg As String
'Check validity of passed parameters.
' Exit sub presenting Msg if not valid
If IsNull("strSQL") Or strSQL = "" Or IsNull("strSearchString") Or
strSearchString = "" Then
strMsg = "SQL-string and/or string to search for is missing."
MsgBox strMsg
Exit Function
Else
Set db = Currentdb()
Set rec = db.OpenRecordset(strSQL)
rec.Index = "PrimaryKey"
' If strSearchString doesn´t exist exit function else get value
If IsNull("rec.Seek " = ", strSearchString") Then
Exit Function
Else
rec.Seek "=", strSearchString
' If value <> 0 send value to calling sub else exit function
If rec("Value") <> 0 Then
SeekStoredCriteria = rec("Value")
Else
Exit Function
End If
End If
End If
End Function