J
Julia B
Hi, I've got the a function within a module that's called to find a record
(returns an integer). On the rs.Open line I get error "-2147467259 Automation
error Unspecified error" which is very unhelpful. I've tested the SQL which
works fine if I create a query using it in my database, so I'm really at a
loss. Can anyone help (it's Access 2003)? Here's the code:
Private Function findPlantRecordNo(Plant As String) As Integer
'called for when creating the new detail level record
Dim rs As New ADODB.Recordset
Dim strSQl As String
strSQl = "SELECT RecordID FROM Plants WHERE Plant = '" + Plant + "' AND
Current = True"
rs.Open strSQl, db, adOpenKeyset, adLockOptimistic, adCmdTableDirect
If rs.RecordCount = 0 Then
findPlantRecordNo = 0
Else
findPlantRecordNo = rs!RecordID
End If
rs.Close
End Function
Thanks
Julia
(returns an integer). On the rs.Open line I get error "-2147467259 Automation
error Unspecified error" which is very unhelpful. I've tested the SQL which
works fine if I create a query using it in my database, so I'm really at a
loss. Can anyone help (it's Access 2003)? Here's the code:
Private Function findPlantRecordNo(Plant As String) As Integer
'called for when creating the new detail level record
Dim rs As New ADODB.Recordset
Dim strSQl As String
strSQl = "SELECT RecordID FROM Plants WHERE Plant = '" + Plant + "' AND
Current = True"
rs.Open strSQl, db, adOpenKeyset, adLockOptimistic, adCmdTableDirect
If rs.RecordCount = 0 Then
findPlantRecordNo = 0
Else
findPlantRecordNo = rs!RecordID
End If
rs.Close
End Function
Thanks
Julia