Problem

k209310

Registered User.
Local time
Today, 18:10
Joined
Aug 14, 2002
Messages
184
Is is possible to search a table to see in a fieldName exists using VBA?
 
Sub SearchField()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim fld As DAO.Field
Dim strField As String
Dim boolExists As Boolean

Set db = CurrentDb
Set tbl = db.TableDefs(InputBox("Please enter table name:", "Table To Be Searched"))

strField = InputBox("Please enter the field name you are searching for:", "Field Search")

For Each fld In tbl.Fields
If fld.Name = strField Then
MsgBox "Exists"
boolExists = True
End If
Next

If boolExists = False Then
MsgBox "The field you are searching for does not exist in that table.", vbOKOnly, "Does Not Exist"
End If

End Sub


Good luck!
 

Users who are viewing this thread

Back
Top Bottom