Connecting Tech Pros Worldwide Forums | Help | Site Map

How to earmark certain tables, differentiating them from others?

MLH
Guest
 
Posts: n/a
#1: Nov 12 '06
Have a database with 100 or more tables.
Would like to set some property to flag those
whose data is dynamic from those tables
containing essentially static reference data.

What's recommended method for this? Am
looking for a method other than some unique
string embedded in table name.

Darryl Kerkeslager
Guest
 
Posts: n/a
#2: Nov 12 '06

re: How to earmark certain tables, differentiating them from others?


1. Use the Database Window's Description field, which is accessible by
right-clicking on the table name and choosing Properties.

2. Do what you don't want to do, and add "some unique
string embedded in table name", like "lu_", as in, "lu_state_code"

--
Darryl Kerkeslager

"MLH" <CRCI@NorthState.netwrote
Quote:
Have a database with 100 or more tables.
Would like to set some property to flag those
whose data is dynamic from those tables
containing essentially static reference data.

Granny Spitz via AccessMonster.com
Guest
 
Posts: n/a
#3: Nov 12 '06

re: How to earmark certain tables, differentiating them from others?


MLH wrote:
Quote:
What's recommended method for this? Am
looking for a method other than some unique
string embedded in table name.
Hon, the recommended method *is* to use part of the table's name, like
Bldg_Lkup or Bldg_Local or Bldg_Lcl, for the front end tables. You can
either use a utility to change the names throughout the application or you
can add a table property to each of the tables and read that property in code
to determine if it's special.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200611/1

MLH
Guest
 
Posts: n/a
#4: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


Am having trouble reading the Description property
after setting it as you recommended. I do like your
recommendation, BTW. Here's the code I tried to
use to read the description. Of course, it is not
working...

Sub TableDefX()

Dim MyDB As Database
Dim MyTDF As TableDef
Set MyDB = CurrentDb

With MyDB
Debug.Print .TableDefs.Count & _
" TableDefs in " & .Name

' Enumerate TableDefs collection.
For Each MyTDF In .TableDefs
Debug.Print " " & MyTDF.Name & " ==" &
MyTDF.Properties.Description
Next MyTDF
End With

End Sub

MLH
Guest
 
Posts: n/a
#5: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


I also tried this code to write table Description
values - having trouble with it as well...

Sub SetDescrips()
On Error GoTo Err_EditTableDescriptions

Dim db As DAO.Database
Dim tbl As DAO.TableDef
Dim prp As DAO.Property
Dim NoDescription As Boolean
Dim DescriptionText As String
Dim TableNameText As String, i As Byte
Set db = CurrentDb

For i = 0 To UBound(ExporTables, 1)
TableNameText = ExporTables(i)
Debug.Print TableNameText
Set tbl = db.TableDefs(TableNameText)
Set prp = tbl.Properties("description")
prp!Description = "ExportTable"
Next i

Exit_EditTableDescriptions:
db.Close
Exit Sub

Err_EditTableDescriptions:
If Err.Number = 3270 Then
NoDescription = True
Resume Next
Else
MsgBox Err.Description
Resume Exit_EditTableDescriptions
End If

End Sub

ExporTables() is an array of table names.
Darryl Kerkeslager
Guest
 
Posts: n/a
#6: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


The description is only a property in the Database Window. AFAIK, it cannot
be accessed via code. It does not exist outside Access, so cannot be seen
from DAO or ADO.

--
Darryl Kerkeslager


"MLH" <CRCI@NorthState.netwrote
Quote:
>I also tried this code to write table Description
values - having trouble with it as well...

MLH
Guest
 
Posts: n/a
#7: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


Ahaaa. Well, that would explain a lot.

I found code on this NG that reads the
property in VBA. Are you saying it cannot
be written?
Darryl Kerkeslager
Guest
 
Posts: n/a
#8: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


"MLH" <CRCI@NorthState.netwrote
Quote:
I found code on this NG that reads the
property in VBA. Are you saying it cannot
be written?
"Cannot" is such a strong word ... so unequivocal.

Not definitively, "no", just as far as I know, "no".

--
Darryl Kerkeslager




David W. Fenton
Guest
 
Posts: n/a
#9: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


"Darryl Kerkeslager" <kerkeslager@comcast.netwrote in
news:PICdnQcru8mP1sTYnZ2dnUVZ_uudnZ2d@comcast.com:
Quote:
The description is only a property in the Database Window. AFAIK,
it cannot be accessed via code. It does not exist outside Access,
so cannot be seen from DAO or ADO.
Are you sure it can't be accessed through the properties collection
of the tabledef? Yes, that's correct -- I just tested it and it's
the 13th item in the properties collection. It won't always be the
13th item, but it should always be in the properties collection *if*
it has been set.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
David W. Fenton
Guest
 
Posts: n/a
#10: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


"Darryl Kerkeslager" <kerkeslager@comcast.netwrote in
news:zaOdnYOigP74X8TYnZ2dnUVZ_s6dnZ2d@comcast.com:
Quote:
"MLH" <CRCI@NorthState.netwrote
Quote:
>I found code on this NG that reads the
>property in VBA. Are you saying it cannot
>be written?
>
"Cannot" is such a strong word ... so unequivocal.
>
Not definitively, "no", just as far as I know, "no".
The properties collection gives you access to it. That's the basica
way that all non-Jet properties are exposed via DAO.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Lyle Fairfield
Guest
 
Posts: n/a
#11: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


Darryl Kerkeslager wrote:
Quote:
"MLH" <CRCI@NorthState.netwrote
Quote:
I found code on this NG that reads the
property in VBA. Are you saying it cannot
be written?
>
"Cannot" is such a strong word ... so unequivocal.
>
Not definitively, "no", just as far as I know, "no".
Dim r As ADODB.Recordset
Set r = CurrentProject.Connection.OpenSchema(adSchemaColum ns,
Array(Empty, Empty, "Table1"))
With r
While Not .EOF
Debug.Print .Fields("COLUMN_NAME").Value, .Fields("Description").Value
..MoveNext
Wend
End With

works for access >= 2k

I suppose one could create an independent ADO connection and get the
same info for <=97 but I have not checked that.

There is much more info available in other columns.

ADO is so bad. It does everything, smoothly, cleanly, quickly.

But Brutus said it was amitious, and Brutus is an honourable man?

Darryl Kerkeslager
Guest
 
Posts: n/a
#12: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?


RE: David's and Lyle's responses

That's why I wouldn't say "cannot."

Someone always seems to know how ...

--
Darryl Kerkeslager


Max Hugen
Guest
 
Posts: n/a
#13: Nov 14 '06

re: How to earmark certain tables, differentiating them from others?



You can add a custom Property to your tables, and set this to reflect
the nature of the data.

For example, running the following in the Immediate Window:

gfAddCustomTableProp("MyTable", "DataClass", "Static")

would add a new property called 'DataClass' and assign it as Static (or
Dynamic, as you require).

The code for the above function is:

' ========= Code Start ==============
Public Function gfAddCustomTableProp%(TableName$, PropName$, PropValue$)
On Error GoTo err_gfAddCustomTableProp
Dim db As Database: Set db = CurrentDb
Dim tdf As TableDef
Dim prp As Property
Dim PropExists%

Set tdf = db.TableDefs(TableName)
Debug.Print tdf.Name & " *********"

For Each prp In tdf.Properties
If prp.Name = PropName Then
PropExists = True
Debug.Print "Property Exists: " & prp.Name, prp.Value
Exit For
End If
Next prp

If Not PropExists Then
Set prp = tdf.CreateProperty(PropName, dbText, PropValue)
tdf.Properties.Append prp

Set prp = tdf.Properties(PropName)
Debug.Print "Property Created: " & prp.Name, prp.Value
End If
Debug.Print ""

gfAddCustomTableProp = True

exit_gfAddCustomTableProp:
Set db = Nothing: Set tdf = Nothing: Set prp = Nothing
Exit Function
err_gfAddCustomTableProp:
MsgBox Err & ": " & Err.Description
Resume exit_gfAddCustomTableProp
End Function
' ========= Code End ==============

HTH.


*** Sent via Developersdex http://www.developersdex.com ***
David W. Fenton
Guest
 
Posts: n/a
#14: Nov 15 '06

re: How to earmark certain tables, differentiating them from others?


"Darryl Kerkeslager" <kerkeslager@comcast.netwrote in
news:pvKdnRnOVOEE2sfYnZ2dnUVZ_vSdnZ2d@comcast.com:
Quote:
RE: David's and Lyle's responses
>
That's why I wouldn't say "cannot."
>
Someone always seems to know how ...
Why answer if all you have to say is "I really don't know" -- you
could have tried it and found out the answer yourself.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Darryl Kerkeslager
Guest
 
Posts: n/a
#15: Nov 15 '06

re: How to earmark certain tables, differentiating them from others?


You're exactly right. I was on the way to work, and penned a quick answer.
On the way to work, I thought again, that there probably was ... but you're
right, maybe I should have just waited.

--
Darryl Kerkeslager
"David W. Fenton" <XXXusenet@dfenton.com.invalidwrote
Quote:
>
Why answer if all you have to say is "I really don't know" -- you
could have tried it and found out the answer yourself.
>
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/

Closed Thread