@@ -16,10 +16,10 @@ Begin Form
16
16
Width =10080
17
17
DatasheetFontHeight =11
18
18
ItemSuffix =241
19
- Left =20761
20
- Top =2250
21
- Right =-29055
22
- Bottom =13995
19
+ Left =3225
20
+ Top =2430
21
+ Right =18945
22
+ Bottom =14175
23
23
RecSrcDt = Begin
24
24
0 x79e78b777268e540
25
25
End
@@ -3435,6 +3435,7 @@ Private Enum eTableCol
3435
3435
etcSystem = 3
3436
3436
etcOther = 4
3437
3437
etcLocal = 5
3438
+ etcLinked = 6
3438
3439
End Enum
3439
3440
3440
3441
Private Enum eMapAction
@@ -3520,76 +3521,89 @@ Private Sub LoadTableList()
3520
3521
Dim intFormat As eTableDataExportFormat
3521
3522
Dim strName As String
3522
3523
Dim lngColumn As eTableCol
3524
+ Dim dbs As DAO .Database
3525
+ Dim rstTableData As DAO .Recordset
3526
+ Dim rstSource As DAO .Recordset
3527
+ Dim strSql As String
3528
+ Dim fld As DAO .Field
3529
+ Dim lngFlags As Long
3530
+ Dim lngType As Long
3523
3531
3524
3532
' Reset list of tables
3525
- CodeDb.Execute "DELETE FROM tblTableData;" , dbFailOnError
3526
-
3533
+ Set dbs = CodeDb
3534
+ dbs.Execute "DELETE FROM tblTableData;" , dbFailOnError
3535
+
3536
+ ' Open table to load records
3537
+ Set rstTableData = dbs.OpenRecordset("SELECT * FROM tblTableData;" , dbOpenDynaset)
3538
+
3527
3539
' Get list of tables if we have a database file open.
3528
3540
If DatabaseFileOpen Then
3529
- Dim strSql As String
3530
- Dim rsSource As DAO .Recordset
3531
- Dim rsTableData As DAO .Recordset
3532
- Dim fld As DAO .Field
3533
-
3541
+
3542
+ ' Note that Access SQL does not support bitwise "and" operator
3543
+ ' (Also known as BAND in ADO) so we will check the bit flags in VBA instead.
3534
3544
strSql = _
3535
- "SELECT " & _
3536
- " o.Name AS TableName, " & _
3537
- " IIf(o.Flags And -2147483646 = -2147483646, 1, 0) AS IsSystem, " & _
3538
- " IIf(o.Flags And 1 = 1, 1, 0) AS IsHidden, " & _
3539
- " IIf(o.Type = 1, 1, 0) AS IsLocal, " & _
3540
- " IIf(o.Type <> 1, 1, 0) AS IsOther " & _
3545
+ "SELECT o.Name, o.Type, o.Flags " & _
3541
3546
"FROM MSysObjects AS o " & _
3542
3547
"WHERE o.Type IN (1, 4, 6) " & _
3543
3548
"ORDER BY o.Name;"
3544
- Set rsSource = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)
3545
- Set rsTableData = CodeDb.OpenRecordset("SELECT * FROM tblTableData;" , dbOpenDynaset)
3546
-
3547
- Do Until rsSource.EOF
3548
- rsTableData.AddNew
3549
- For Each fld In rsSource.Fields
3550
- rsTableData.Fields(fld.Name).Value = fld.Value
3551
- Next
3552
- Select Case True
3553
- Case Nz(rsSource.Fields("IsSystem" ).Value, False )
3554
- lngColumn = etcSystem
3555
- Case Nz(rsSource.Fields("IsLocal" ).Value, False )
3556
- lngColumn = etcLocal
3557
- Case Nz(rsSource.Fields("IsOther" ).Value, False )
3558
- lngColumn = etcOther
3559
- Case Else
3560
- lngColumn = -1
3561
- End Select
3562
- rsTableData.Fields("TableIcon" ).Value = GetTableIcon(lngColumn)
3563
- rsTableData.Update
3564
- rsSource.MoveNext
3565
- Loop
3566
-
3567
- ' Add in the list of saved tables, adding into the sorted location
3568
- If Not Options.TablesToExportData Is Nothing Then
3569
- ' Loop through each table in the saved table list
3570
- For Each varKey In Options.TablesToExportData.Keys
3571
- strName = CStr(varKey)
3572
- strFormat = Options.TablesToExportData.Item(varKey)("Format" )
3573
- intFormat = Options.GetTableExportFormat(strFormat)
3574
-
3575
- With rsTableData
3576
- .FindFirst "[TableName]='" & Replace$(strName, "'" , "''" ) & "'"
3577
- If .EOF Then
3578
- .AddNew
3579
- .Fields("TableName" ).Value = strName
3580
- .Fields("TableIcon" ).Value = GetTableIcon(etcOther)
3581
- .Fields("FormatType" ).Value = intFormat
3582
- .Fields("IsOther" ).Value = True
3583
- .Update
3584
- Else
3585
- .Edit
3586
- .Fields("FormatType" ).Value = intFormat
3587
- .Update
3588
- End If
3589
- End With
3590
- Next varKey
3591
- End If
3549
+
3550
+ Set rstSource = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot)
3551
+ With rstSource
3552
+ Do While Not .EOF
3553
+ ' Determine type of table
3554
+ lngFlags = Nz(!Flags, 0 )
3555
+ lngType = Nz(!Type , 0 )
3556
+ If (lngFlags < 0 ) Or BitSet(lngFlags, 1 ) Then
3557
+ ' Don't include read-only or deeply hidden system tables.
3558
+ ' https://isladogs.co.uk/purpose-of-system-tables-2/index.html#TFE
3559
+ Else
3560
+ rstTableData.AddNew
3561
+ rstTableData!TableName = Nz(!Name)
3562
+ rstTableData!Flags = Nz(!Flags)
3563
+ rstTableData!IsSystem = ((lngFlags <> 0 ) And (lngFlags <> 8 ) And (lngType = 1 ))
3564
+ rstTableData!IsHidden = BitSet(lngFlags, 8 )
3565
+ rstTableData!IsLocal = (lngType = 1 )
3566
+ ' Determine table icon
3567
+ rstTableData!TableIcon = GetTableIcon(etcLinked) ' Default to linked table if no match.
3568
+ If rstTableData!IsLocal Then rstTableData!TableIcon = GetTableIcon(etcLocal)
3569
+ If rstTableData!IsSystem Then rstTableData!TableIcon = GetTableIcon(etcSystem)
3570
+ rstTableData.Update
3571
+ End If
3572
+ .MoveNext
3573
+ Loop
3574
+ .Close
3575
+ End With
3576
+ End If
3577
+
3578
+ ' Add in the list of saved tables, adding into the sorted location
3579
+ If Not Options.TablesToExportData Is Nothing Then
3580
+ ' Loop through each table in the saved table list
3581
+ For Each varKey In Options.TablesToExportData.Keys
3582
+ strName = CStr(varKey)
3583
+ strFormat = Options.TablesToExportData.Item(varKey)("Format" )
3584
+ intFormat = Options.GetTableExportFormat(strFormat)
3585
+
3586
+ With rstTableData
3587
+ .FindFirst "[TableName]='" & Replace$(strName, "'" , "''" ) & "'"
3588
+ If .NoMatch Then
3589
+ .AddNew
3590
+ !TableName = strName
3591
+ !TableIcon = GetTableIcon(etcOther)
3592
+ !FormatType = intFormat
3593
+ !IsOther = True
3594
+ .Update
3595
+ Else
3596
+ .Edit
3597
+ !FormatType = intFormat
3598
+ .Update
3599
+ End If
3600
+ End With
3601
+ Next varKey
3592
3602
End If
3603
+
3604
+ ' Close recordset after adding records
3605
+ rstTableData.Close
3606
+
3593
3607
End Sub
3594
3608
3595
3609
@@ -3601,25 +3615,31 @@ End Sub
3601
3615
'---------------------------------------------------------------------------------------
3602
3616
'
3603
3617
Private Sub SaveTableList ()
3604
- Dim rsTableData As DAO .Recordset
3605
- Dim dTables As Scripting .Dictionary
3606
- Dim dTable As Scripting .Dictionary
3618
+
3619
+ Dim rstTableData As DAO .Recordset
3620
+ Dim dTables As Dictionary
3621
+ Dim dTable As Dictionary
3607
3622
3608
3623
' Save list of tables to export data
3609
- Set dTables = New Scripting. Dictionary
3624
+ Set dTables = New Dictionary
3610
3625
dTables.CompareMode = TextCompare
3611
3626
3612
- Set rsTableData = CodeDb.OpenRecordset("SELECT TableName, FormatType FROM tblTableData WHERE FormatType <> 0 ORDER BY TableName;" , dbOpenForwardOnly)
3613
- Do Until rsTableData.EOF
3614
- Set dTable = New Scripting.Dictionary
3615
- dTable.CompareMode = TextCompare
3616
- dTable("Format" ) = Options.GetTableExportFormatName(rsTableData.Fields("FormatType" ).Value)
3617
- dTables.Add rsTableData.Fields("TableName" ).Value, dTable
3618
-
3619
- rsTableData.MoveNext
3620
- Loop
3627
+ Set rstTableData = CodeDb.OpenRecordset( _
3628
+ "SELECT TableName, FormatType FROM tblTableData " & _
3629
+ "WHERE FormatType <> 0 ORDER BY TableName;" , dbOpenForwardOnly)
3630
+ With rstTableData
3631
+ Do Until .EOF
3632
+ Set dTable = New Dictionary
3633
+ dTable.CompareMode = TextCompare
3634
+ dTable("Format" ) = Options.GetTableExportFormatName(Nz(!FormatType, 0 ))
3635
+ dTables.Add Nz(!TableName), dTable
3636
+ .MoveNext
3637
+ Loop
3638
+ .Close
3639
+ End With
3621
3640
3622
3641
Set Options.TablesToExportData = dTables
3642
+
3623
3643
End Sub
3624
3644
3625
3645
@@ -3631,33 +3651,38 @@ End Sub
3631
3651
'---------------------------------------------------------------------------------------
3632
3652
'
3633
3653
Private Sub AddUpdateTableInList (strName As String , lngFormatType As eTableDataExportFormat , blnHidden As Boolean , blnSystem As Boolean , blnOther As Boolean , blnLocal As Boolean )
3634
- Dim rsClone As DAO .Recordset
3635
- Dim rsActive As DAO .Recordset
3636
3654
3637
- Set rsClone = Me.sfrmTableData.Form.RecordsetClone
3638
- Set rsActive = Me.sfrmTableData.Form .Recordset
3655
+ Dim rstClone As DAO .Recordset
3656
+ Dim rstActive As DAO .Recordset
3639
3657
3640
- With rsActive
3641
- rsClone.FindFirst "TableName='" & Replace$(strName, "'" , "''" ) & "'"
3658
+ Set rstClone = Me.sfrmTableData.Form.RecordsetClone
3659
+ Set rstActive = Me.sfrmTableData.Form.Recordset
3642
3660
3643
- If rsClone.NoMatch Then
3661
+ With rstActive
3662
+
3663
+ ' Look for matching table name
3664
+ rstClone.FindFirst "TableName='" & Replace$(strName, "'" , "''" ) & "'"
3665
+ If rstClone.NoMatch Then
3666
+ ' Add new table to this list
3644
3667
Me.sfrmTableData.Form.AllowAdditions = True
3645
3668
.AddNew
3646
- .Fields( " TableName" ).Value = strName
3647
- .Fields( " TableIcon" ).Value = GetTableIcon(etcOther)
3669
+ ! TableName = strName
3670
+ ! TableIcon = GetTableIcon(etcOther)
3648
3671
Else
3649
- .Bookmark = rsClone .Bookmark
3672
+ .Bookmark = rstClone .Bookmark
3650
3673
.Edit
3651
3674
End If
3652
3675
3653
- .Fields("FormatType" ).Value = lngFormatType
3654
- .Fields("IsHidden" ).Value = blnHidden
3655
- .Fields("IsSystem" ).Value = blnSystem
3656
- .Fields("IsOther" ).Value = blnOther
3657
- .Fields("IsLocal" ).Value = blnLocal
3676
+ ' Update remaining fields
3677
+ !FormatType = lngFormatType
3678
+ !IsHidden = blnHidden
3679
+ !IsSystem = blnSystem
3680
+ !IsOther = blnOther
3681
+ !IsLocal = blnLocal
3658
3682
.Update
3659
3683
Me.sfrmTableData.Form.AllowAdditions = False
3660
3684
End With
3685
+
3661
3686
End Sub
3662
3687
3663
3688
@@ -3711,9 +3736,11 @@ Private Sub RefreshTableDisplay()
3711
3736
3712
3737
Me.sfrmTableData.Form.RecordSource = strSql
3713
3738
3714
- Me.lblTableShowHidden.Caption = GetCaptionWithCount("Show Hidden" , "SELECT COUNT(d.TableName) FROM tblTableData AS d WHERE d.IsHidden <> 0 AND d.FormatType <> 0;" )
3715
- Me.lblTableShowSystem.Caption = GetCaptionWithCount("Show System" , "SELECT COUNT(d.TableName) FROM tblTableData AS d WHERE d.IsSystem <> 0 AND d.FormatType <> 0;" )
3716
- Me.lblTableShowOther.Caption = GetCaptionWithCount("Show Other" , "SELECT COUNT(d.TableName) FROM tblTableData AS d WHERE d.IsOther <> 0 AND d.FormatType <> 0;" )
3739
+ ' Update captions with counts
3740
+ Me.lblTableShowHidden.Caption = GetCaptionWithCount("Show Hidden" , "d.IsHidden = True AND d.IsSystem = " & chkTableShowSystem)
3741
+ Me.lblTableShowSystem.Caption = GetCaptionWithCount("Show System" , "d.IsSystem = True AND d.IsHidden = " & chkTableShowHidden)
3742
+ Me.lblTableShowOther.Caption = GetCaptionWithCount("Show Other " , "d.IsOther = True" )
3743
+
3717
3744
End Sub
3718
3745
3719
3746
@@ -3724,24 +3751,32 @@ End Sub
3724
3751
' Purpose : Provides caption with a count appended if non-zero.
3725
3752
'---------------------------------------------------------------------------------------
3726
3753
'
3727
- Private Function GetCaptionWithCount (TemplateCaption As String , CountSQL As String ) As String
3754
+ Private Function GetCaptionWithCount (TemplateCaption As String , CountFilter As String ) As String
3728
3755
Dim rs As DAO .Recordset
3729
- Set rs = CodeDb.OpenRecordset(CountSQL, dbOpenSnapshot)
3756
+ Set rs = CodeDb.OpenRecordset( _
3757
+ "SELECT COUNT(d.TableName) FROM tblTableData AS d WHERE " & CountFilter, dbOpenSnapshot)
3730
3758
If rs.EOF = False Then
3731
3759
If Nz(rs.Fields(0 ).Value, 0 ) Then
3732
3760
GetCaptionWithCount = TemplateCaption & " (" & rs.Fields(0 ).Value & ")"
3733
3761
Exit Function
3734
3762
End If
3735
3763
End If
3736
-
3737
3764
GetCaptionWithCount = TemplateCaption
3738
3765
End Function
3739
3766
3740
3767
3768
+ '---------------------------------------------------------------------------------------
3769
+ ' Procedure : cmdOpenInstallFolder_Click
3770
+ ' Author : Adam Waller
3771
+ ' Date : 7/6/2023
3772
+ ' Purpose : Open the installation folder
3773
+ '---------------------------------------------------------------------------------------
3774
+ '
3741
3775
Private Sub cmdOpenInstallFolder_Click ()
3742
3776
Application.FollowHyperlink modInstall.GetInstallSettings.strInstallFolder
3743
3777
End Sub
3744
3778
3779
+
3745
3780
'---------------------------------------------------------------------------------------
3746
3781
' Procedure : cmdRestoreDefaults_Click
3747
3782
' Author : Adam Waller
@@ -3883,7 +3918,7 @@ Private Sub MapControlsToOptions(eAction As eMapAction)
3883
3918
Dim pge As Access .Page
3884
3919
Dim ctl As Access .Control
3885
3920
Dim strKey As String
3886
- Dim dSettings As Scripting . Dictionary
3921
+ Dim dSettings As Dictionary
3887
3922
3888
3923
' Loop through each page
3889
3924
For Each pge In tabOptions.Pages
@@ -4024,6 +4059,7 @@ Private Sub txtExportFolder_BeforeUpdate(Cancel As Integer)
4024
4059
4025
4060
End Sub
4026
4061
4062
+
4027
4063
'---------------------------------------------------------------------------------------
4028
4064
' Procedure : GetTableIcon
4029
4065
' Author : Adam Waller & Indigo744
@@ -4049,7 +4085,7 @@ Private Function GetTableIcon(ByRef lngColumn As eTableCol) As String
4049
4085
' http://www.fileformat.info/info/unicode/char/21aa/index.htm
4050
4086
GetTableIcon = ChrW$(8618 )
4051
4087
Case Else
4052
- ' Everything else are linked table
4088
+ ' Anything else would be a linked table
4053
4089
' Uses symbol EARTH GLOBE AMERICAS
4054
4090
' https://www.fileformat.info/info/unicode/char/1f30e/index.htm
4055
4091
GetTableIcon = ChrW$(55356 ) & ChrW$(57102 )
0 commit comments