Table Analyser and compair versions analyser (1 Viewer)

Dreamweaver

Well-known member
Local time
Today, 14:46
Joined
Nov 28, 2005
Messages
2,466
Hi All I'm in the process of updating/Correcting an old program from 2005 I built


I have a table analyser which records all table, relations, indexes, fields and field properties.


The Idear back in the day was to compair to versions of a data file I.E. old version and new version so I could create an update which is still my plan but I find myself unable to decide on how to approch the compair I could do it in code but was wondering if there was a way in queries I'm not that good with complex queries but feel it would be faster than a code version esp on large databases with hundreds of tables.


Any advice would be more than welcome


view Analyser screenshots here: https://databasedreams.createaforum...table-analyser-and-compair-versions-analyser/
 

Dreamweaver

Well-known member
Local time
Today, 14:46
Joined
Nov 28, 2005
Messages
2,466
No Fun In that lol Much rather build my own and learn a few tricks even if I need help in doing so but thanks though.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 14:46
Joined
Jan 14, 2017
Messages
18,211
There's also the built in database documenter which does everything you listed
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:46
Joined
Sep 21, 2011
Messages
14,238
Well, I would probably just use this one by Crystal...
http://www.accessmvp.com/strive4peace/analyzer.htm

Gina,
Have you used this successfully?
I have tried a mdb and an accdb and it fails each time on the line in the picture
The fld in question is ID the autonumber field.?

I would love to be able to use this. Where would I report the problem, if it is not something I am doing incorrectly.?

Basically all I have done is open the file, see the initialisation and then select the Run Analyzer.

TIA
 

Attachments

  • analyser.PNG
    analyser.PNG
    66.6 KB · Views: 108

Dreamweaver

Well-known member
Local time
Today, 14:46
Joined
Nov 28, 2005
Messages
2,466
There's also the built in database documenter which does everything you listed


Didn't think it would check for differences between two databases I.E. Version 1 and 2 what I intend is to write the differnces to table(s) so I can either add missing tables in version 1 and if able update any fields in excisting tables in version 1
 

isladogs

MVP / VIP
Local time
Today, 14:46
Joined
Jan 14, 2017
Messages
18,211
Didn't think it would check for differences between two databases I.E. Version 1 and 2 what I intend is to write the differnces to table(s) so I can either add missing tables in version 1 and if able update any fields in excisting tables in version 1

True. It won't do that.
For a list of objects, all you need is to link to the MSysObjects table in both databases and analyse the contents of each. Beyond that, it will depend on what else you want to do
 

Dreamweaver

Well-known member
Local time
Today, 14:46
Joined
Nov 28, 2005
Messages
2,466
Thanks I didn't think of them I'll check to see what lvl of detail I can get from them the code I'm looking at Updating/Correcting and finishing was started in 2005 so looking at my options as to best way to go.
 

GinaWhipp

AWF VIP
Local time
Today, 09:46
Joined
Jun 21, 2011
Messages
5,900
@Gasman,

I have not used but only because never needed. That said, down at the bottom of the page there is a link to send Crystal eMail.
 

GinaWhipp

AWF VIP
Local time
Today, 09:46
Joined
Jun 21, 2011
Messages
5,900
@Gasman,

I have also sent her a message and a link. I am not sure if she is a member of this Forum but figured it couldn't hurt. :D
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:46
Joined
Sep 21, 2011
Messages
14,238
Thank you Gina,
I'll report the issue and see what they say.

Perhaps 2007 autonumber does not have an expression property?, but I am wondering if any autonumber would have one, due to their use.?

Look very impressive I must say.
 

GinaWhipp

AWF VIP
Local time
Today, 09:46
Joined
Jun 21, 2011
Messages
5,900
No problem!

Hmm, never even considered that about autonumbers but I would say no. :confused: Would be nice to know if I was right or wrong.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:46
Joined
Jul 9, 2003
Messages
16,274
I too like rolling my own!

A few years ago I built my own, but it's not just an analyzer, it can also add in missing fields for you. Basically you import the tables from your production database, use the analyzer to check against the equivalent tables in your development database. It will tell you if you have any new Fields or if you have removed any fields. If you have added extra fields in your development environment then you have the option of automatically adding the new field(s) to the production database. It also notifies you of any changes you have made to the fields, like maybe you increased/decreased the size of a text field in the development database. You can then decide if you want to make those changes in the production table(s).

It will also notify you if you have added any new tables, or if you have deleted any tables...
 
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:46
Joined
Jul 9, 2003
Messages
16,274
Oh! -- In answer to your question, mine was purely VBA, it was designed to analyze the structure of the tables not the content of the tables...

I definitely didn't use any Queries, however I might have used some SQL Statements in the VBA code. I'll have a look as soon as I can and let you know...
 

Dreamweaver

Well-known member
Local time
Today, 14:46
Joined
Nov 28, 2005
Messages
2,466
Thanks uncle that's exactly what I'm trying to do ill go the van rout
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:46
Joined
Sep 21, 2011
Messages
14,238
Well, I would probably just use this one by Crystal...
http://www.accessmvp.com/strive4peace/analyzer.htm

Gina,
Just got off Skype with Crystal. What a lovely lady.:)
She wanted to get the problem sorted immediately and in doing so, showed me a few tricks in Access. She spent over 90 minutes with me. :cool:

Thank you for the link.

I would say to the experts that her Analyser is certainly worth looking at. I know that Access has its own documenter, but this is something else.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:46
Joined
Sep 21, 2011
Messages
14,238
No Fun In that lol Much rather build my own and learn a few tricks even if I need help in doing so but thanks though.

Now see, I am a firm believer of not re-inventing the wheel.:D

I'd be more than happy to contribute to such a project if I had the skills and offer suggestions for anything I thought would also be useful rather than start from scratch.
 

GinaWhipp

AWF VIP
Local time
Today, 09:46
Joined
Jun 21, 2011
Messages
5,900
Just got off Skype with Crystal. What a lovely lady.
She wanted to get the problem sorted immediately and in doing so, showed me a few tricks in Access. She spent over 90 minutes with me.

So glad you got that worked out!

Yep, Crystal is pretty nice!
 

Dreamweaver

Well-known member
Local time
Today, 14:46
Joined
Nov 28, 2005
Messages
2,466
Oh! -- In answer to your question, mine was purely VBA, it was designed to analyze the structure of the tables not the content of the tables...

I definitely didn't use any Queries, however I might have used some SQL Statements in the VBA code. I'll have a look as soon as I can and let you know...


Hope somebody can help with this I've been trying to solve this problem I can link back to the related table for indexes but linking Indexes to a table field is proving hard the code I'm using is below plus have added a picture



Public Sub DoIndexes(ByVal tbl, ObjID As Long)
Dim CDb As DAO.Database
Dim db As DAO.Database
Dim Idx As Index
Dim tdf As TableDef
Dim Prop As Property
Dim m_RecIndex As DAO.Recordset
Set db = CurrentDb()
Set tdf = AsDb.TableDefs(tbl)
Set m_RecIndex = db.OpenRecordset("SELECT * FROM tblProjectObjectIndexes", dbOpenDynaset, dbAppendOnly) 'UPDATED 19/11/2018
'On Error Resume Next
For Each Idx In tdf.Indexes
For Each Prop In Idx.Properties
If Prop.Name = "Value" Then
'Do Nothing
Else
With m_RecIndex
.AddNew
!ObjectID = ObjID
!InheritedFrom = Prop.Inherited
!PropName = Prop.Name
!PropValue = Prop.Value
If Not IsNothing(Prop.Properties) Then !Props = Prop.Properties
!IndxType = Prop.Type
.Update
End With
End If
Next Prop
Next Idx
End Sub


Edit I can code a way of linking most fields those with field names but ones with just primary key wont resolve unless I'm missing something


thanks in advance
 

Attachments

  • 2018-11-19.png
    2018-11-19.png
    40.9 KB · Views: 99
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:46
Joined
May 21, 2018
Messages
8,525
I do not know if this will be helpful, but here is some code that does some of this. I use it for posting to forums. I got some of the index in there, but do not understand specifically what you are asking.

Code:
'************************ Class Code Start ****************************************************

Public Function fncDocumentTables() As String
  Dim strDocument As String
  Dim tblDef As DAO.TableDef
  Dim fld As DAO.Field
  Dim strSql As String
  For Each tblDef In CurrentDb.TableDefs
    If Not Left(tblDef.Name, 4) = "MSys" Then
      strDocument = strDocument & vbCrLf & tblDef.Name & vbCrLf
      For Each fld In tblDef.Fields
        strDocument = strDocument & "   " & fld.Name & "   " & fncFldTypeToString(fld.Type)
        If isPK(tblDef, fld.Name) Then
          strDocument = strDocument & "  PrimaryKey"
        End If
        If isFK(tblDef, fld.Name) Then
          strDocument = strDocument & "  ForiegnKey"
        End If
        If isIndex(tblDef, fld.Name) Then
          strDocument = strDocument & "  Indexed"
        End If
        If fld.required Then
           strDocument = strDocument & "  Required"
        End If
        strDocument = strDocument & vbCrLf
      Next fld
     End If
  Next tblDef
  fncDocumentTables = strDocument
End Function

Public Function WriteTables() As String
  Dim strDocument As String
  Dim tblDef As DAO.TableDef
  Dim fld As DAO.Field
  Dim strSql As String
  Dim tableName As String
  Dim fieldName As String
  Dim strDataType As String
  Dim keyType As String
  Dim strIndexed As String
  Dim strRequired As String
  strSql = "INSERT INTO tblTables (TableName,FieldName,DataType,KeyType,Indexed, Required) Values ("
  For Each tblDef In CurrentDb.TableDefs
    If Not Left(tblDef.Name, 4) = "MSys" Then
      strDocument = strDocument & vbCrLf & tblDef.Name & vbCrLf
      For Each fld In tblDef.Fields
        strDocument = strDocument & "   " & fld.Name & "   " & fncFldTypeToString(fld.Type)
        If isPK(tblDef, fld.Name) Then
          strDocument = strDocument & "  PrimaryKey"
        End If
        If isFK(tblDef, fld.Name) Then
          strDocument = strDocument & "  ForiegnKey"
        End If
        If isIndex(tblDef, fld.Name) Then
          strDocument = strDocument & "  Indexed"
        End If
        If fld.required Then
           strDocument = strDocument & "  Required"
        End If
        strDocument = strDocument & vbCrLf
      Next fld
     End If
  Next tblDef
  fncDocumentTables = strDocument
End Function

Public Function fncFldTypeToString(intFieldType As Integer) As String
  Select Case intFieldType
    Case 1
      fncFldTypeToString = "dbBoolean"
    Case 2
      fncFldTypeToString = "dbByte"
    Case 3
      fncFldTypeToString = "dbInteger"
    Case 4
      fncFldTypeToString = "dbLong"
    Case 5
       fncFldTypeToString = "dbCurrency"
    Case 6
      fncFldTypeToString = "dbSingle"
    Case 7
      fncFldTypeToString = "dbDouble"
    Case 8
      fncFldTypeToString = "dbDate"
    Case 9
      fncFldTypeToString = "dbBinary"
    Case 10
      fncFldTypeToString = "dbText"
    Case 11
      fncFldTypeToString = "dbLongBinary"
    Case 12
      fncFldTypeToString = "dbMemo"
    Case 13
      fncFldTypeToString = "Text"
    Case 14
      fncFldTypeToString = "Text"
    Case 15
      fncFldTypeToString = "dbGUID"
    Case 16
      fncFldTypeToString = "dbBigInt"
    Case 17
      fncFldTypeToString = "dbVarBinary"
    Case 18
      fncFldTypeToString = "dbChar"
    Case 19
      fncFldTypeToString = "dbNumeric"
    Case 20
      fncFldTypeToString = "dbDecimal"
    Case 21
      fncFldTypeToString = "dbFloat"
    Case 22
      fncFldTypeToString = "dbTime"
    Case 23
      fncFldTypeToString = "dbTimeStamp"
  End Select
End Function

Public Function isPK(tblDef As DAO.TableDef, strField As String) As Boolean
  Dim idx As DAO.Index
  Dim fld As DAO.Field
  For Each idx In tblDef.Indexes
    If idx.Primary Then
      For Each fld In idx.Fields
        If strField = fld.Name Then
          isPK = True
          Exit Function
        End If
      Next fld
    End If
  Next idx
End Function

Public Function isIndex(tblDef As DAO.TableDef, strField As String) As Boolean
  Dim idx As DAO.Index
  Dim fld As DAO.Field
  For Each idx In tblDef.Indexes
     For Each fld In idx.Fields
        If strField = fld.Name Then
          isIndex = True
          Exit Function
         End If
      Next fld
  Next idx
End Function

Public Function isFK(tblDef As DAO.TableDef, strField As String) As Boolean
  Dim idx As DAO.Index
  Dim fld As DAO.Field
  For Each idx In tblDef.Indexes
    If idx.Foreign Then
      For Each fld In idx.Fields
        If strField = fld.Name Then
          isFK = True
          Exit Function
        End If
      Next fld
    End If
  Next idx
End Function


Public Function fncDocumentRelations() As String
  Dim strDocument As String
  Dim rel As DAO.Relation
  Dim fld As DAO.Field
  Dim idx As DAO.Index
  Dim prop As DAO.Property
  For Each rel In CurrentDb.relations
      strDocument = strDocument & vbCrLf & "Name: " & rel.Name & vbCrLf
      strDocument = strDocument & "  " & "Table: " & rel.Table & vbCrLf
      strDocument = strDocument & "  " & "Foreign Table: " & rel.ForeignTable & vbCrLf
      For Each fld In rel.Fields
        strDocument = strDocument & "  PK: " & fld.Name & "   FK:" & fld.ForeignName
        strDocument = strDocument & vbCrLf
      Next fld
  Next rel
  fncDocumentRelations = strDocument
  
End Function

Public Function fncDocumentQueries() As String
  Dim strDocument As String
  Dim qryDef As DAO.QueryDef
  Dim fld As DAO.Field
  Dim idx As DAO.Index
  
  For Each qryDef In CurrentDb.QueryDefs
    If Not (Left(qryDef.Name, 4) = "MSys" Or Left(qryDef.Name, 4) = "~sq_") Then
      strDocument = strDocument & vbCrLf & qryDef.Name & vbCrLf
      For Each fld In qryDef.Fields
        strDocument = strDocument & "   " & fld.Name & "   " & fncFldTypeToString(fld.Type)
        strDocument = strDocument & vbCrLf
      Next fld
        strDocument = strDocument & qryDef.SQL & vbCrLf
     End If
  Next qryDef
  fncDocumentQueries = strDocument
End Function

Public Sub DocumentTables()
  Debug.Print fncDocumentTables
End Sub

Public Sub DocumentRelations()
  Debug.Print fncDocumentRelations
End Sub

Public Sub DocumentQueries()
  Debug.Print fncDocumentQueries
End Sub
 

Users who are viewing this thread

Top Bottom