Verify field name

T

Tim

Hi folks,

I need a help to verify the field name of a table. A
table named tbltest in my database. I need some code to
check that the second field name equal to “f2” or not. If
not, error message.

Any help will be great appreciated.

Thanks in advance.

Tim.
 
M

medialint

Sub CheckField()
If CurrentDb.TableDefs("tbltest").Fields(1).Name = "f2" Then
MsgBox "The second field is correct"
Else
MsgBox "The second field is incorrect"
End If
End Sub

Note: 1 = 2 when you count from 0 ;)
 
T

Tim

medialint,

The code works great.

Thanks.

Tim.
-----Original Message-----
Sub CheckField()
If CurrentDb.TableDefs("tbltest").Fields(1).Name = "f2" Then
MsgBox "The second field is correct"
Else
MsgBox "The second field is incorrect"
End If
End Sub

Note: 1 = 2 when you count from 0 ;)


.
 

Ask a Question

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.

Ask a Question

Top