Article ID: 132019
Article Last Modified on 11/6/2000
Form: Test1
------------------
Caption: TestForm1
Command button:
Name: ButtonTest
Caption: Test
OnClick: [Event Procedure]
Sub ButtonTest_Click ()
On Local Error Resume Next
Dim i As Integer, UserMessage As String
Dim db As Database, tdef As TableDef
Dim fld As Field, prp As Property
Dim TestCaption As String
Set db = dbEngine.Workspaces(0).Databases(0)
' Test the local table.
Set tdef = db.Tabledefs("LocalProducts")
Set fld = tdef.Fields("Product ID")
TestCaption = fld.Properties("Caption")
If Err = 3270 Then ' Caption does not exist.
UserMessage = "The LocalProducts Tables Caption Property_
is Null!"
Else
UserMessage = "The LocalProducts Table's Caption is [" &_
TestCaption & "]"
End If
MsgBox UserMessage
' Test the attached table.
Set tdef = db.Tabledefs("AttachedProducts")
Set fld = tdef.Fields("Product ID")
TestCaption = fld.Properties("Caption")
If Err = 3270 Then ' Caption does not exist
UserMessage = "The AttachedProducts Table's Caption Property_
is Null!"
Else
UserMessage = "The AttachedProducts Table's Caption is [" &_
TestCaption & "]"
End If
MsgBox UserMessage
ButtonTest_Click_End:
Exit Sub
ButtonTest_Click_Err:
MsgBox Error$
Resume ButtonTest_Click_End
End Sub
The LocalProducts Table's Caption Property is Null!
The AttachedProducts Table's Caption Property is Null!
The LocalProducts Table's Caption is [LocalProducts Caption]
The AttachedProducts Table's Caption Property is Null!
The LocalProducts Table's Caption is [LocalProducts Caption]
The AttachedProducts Table's Caption Property is Null!
Form: Test2
------------------
Caption: TestForm2
Command button:
Name: ButtonTest
Caption: Test
OnClick: [Event Procedure]
Sub ButtonTest_Click ()
On Local Error Resume Next
Dim i As Integer, UserMessage As String
Dim db As Database, tdef As TableDef
Dim fld As Field, prp As Property
Dim TestCaption As String
Set db = dbEngine.Workspaces(0).Databases(0)
' Test the local table.
Set tdef = db.Tabledefs("LocalProducts")
Set fld = tdef.Fields("Product ID")
TestCaption = fld.Properties("Caption")
If Err = 3270 Then ' Caption does not exist
UserMessage = "The LocalProducts Tables Caption Property_
is Null!"
Else
UserMessage = "The LocalProducts Table's Caption is [" &_
TestCaption & "]"
End If
MsgBox UserMessage
' Test the attached table using the OpenDatabase method.
Set db = OpenDatabase("C:\ACCESS\SAMPAPPS\NWIND.MDB")
Set tdef = db.Tabledefs("Products")
Set fld = tdef.Fields("Product ID")
TestCaption = fld.Properties("Caption")
If Err = 3270 Then ' Caption does not exist.
UserMessage = "The AttachedProducts Table's Caption Property_
is Null!"
Else
UserMessage = "The AttachedProducts Table's Caption is [" &_
TestCaption & "]"
End If
MsgBox UserMessage
ButtonTest_Click_End:
Exit Sub
ButtonTest_Click_Err:
MsgBox Error$
Resume ButtonTest_Click_End
End Sub
The LocalProducts Table's Caption is [LocalProducts Caption]
The AttachedProducts Table's Caption is [AttachedProducts Caption]
Keywords: kberrmsg kbinfo kbprogramming KB132019