ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Recordset.FindFirst argument not working... (https://www.excelbanter.com/excel-worksheet-functions/135616-recordset-findfirst-argument-not-working.html)

[email protected]

Recordset.FindFirst argument not working...
 
Hello all! I have the following code and no matter how I change it
around, even though the access table is COMPLETELY empty, it still
seems to think the record exists in my Access Database table and
always kicks off to the MsgBox "Record Found in Table". So either
the .FindFirst isn't working or there another way to rewrite it so it
does work.

Dim AccessDB As Database
Dim AccessRecordSet As Recordset
Dim FindThis As String

Set AccessDB = OpenDatabase("C:\MyDatabase.mdb")
Set AccessRecordSet = AccessDB.OpenRecordset("MyTable",
dbOpenTable)

FindThis = Range("A1").Value

On Error Resume Next
With AccessRecordSet
.FindFirst "[Field1]= '" & FindThis &"'"

If AccessRecordSet.NoMatch Then
MsgBox "Record Not Found in Table"
Else
MsgBox "Record Found in Table"
End If

End With

Again, I've cleared the entire contents of the Access table to test
whether or not the .FindFirst was actually working and it still tells
me that a record WAS found. I'm at a loss.



All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com