D
Deleted member 73419
Guest
Hi,
When I run this code, I get a 'Object Invalid or No Longer Set' error
I have heard it's something to do with using CurrentDB but I'm using it in other functions within the module and it's fine.
I can also see that the table 'Bands' also exists.
Anyone got any ideas?
Thanks
When I run this code, I get a 'Object Invalid or No Longer Set' error
Code:
Function FieldExists(strTableName As String, strFieldName As String) As Boolean
Dim fld As Field
For Each fld In CurrentDb.TableDefs(strTableName).Fields
' If (StrComp(strFieldName, fld.Name, vbTextCompare) = 0) Then
' FieldExists = True
' Exit Function
' End If
Next
' FieldExists = False
End Function
Sub test_FieldExists()
Debug.Print FieldExists("Bands", "cat")
End Sub
I have heard it's something to do with using CurrentDB but I'm using it in other functions within the module and it's fine.
I can also see that the table 'Bands' also exists.
Anyone got any ideas?
Thanks