Public Function FindFieldName(strTblName As String, strFldName As String) As
Boolean
Dim tdfs As TableDefs
Dim tdf As TableDef
Dim flds As Fields
Dim fld As Field
On Error GoTo FindFieldName_Error
FindFieldName = False
Set tdfs = CurrentDb.TableDefs
Set tdf = tdfs(strTblName)
Set flds = tdf.Fields
For Each fld In flds
If fld.Name = strFldName Then
FindFieldName = True
Exit For
End If
Next fld
FindFieldName_Exit:
On Error Resume Next
Exit Function
FindFieldName_Error:
If Err.Number = 3265 Then
MsgBox "Table " & strTblName & " Not Found"
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure FindFieldName of Module modUtilities"
End If
GoTo FindFieldName_Exit
End Function
Public Function FindFieldName(strTblName As String, strFldName As
String) As Boolean
Dim tdfs As TableDefs
Dim tdf As TableDef
Dim flds As Fields
Dim fld As Field
On Error GoTo FindFieldName_Error
FindFieldName = False
Set tdfs = CurrentDb.TableDefs
Set tdf = tdfs(strTblName)
Set flds = tdf.Fields
For Each fld In flds
If fld.Name = strFldName Then
FindFieldName = True
Exit For
End If
Next fld
FindFieldName_Exit:
On Error Resume Next
Exit Function
FindFieldName_Error:
If Err.Number = 3265 Then
MsgBox "Table " & strTblName & " Not Found"
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure FindFieldName of Module modUtilities"
End If
GoTo FindFieldName_Exit
End Function
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.