Skip to content

Commit ca3a368

Browse files
authored
v1.3.2 (#8)
* v1.3.2: use %appdata%\AccessCodeLib instead of %appdata%\AccessCodeLibrary for config data
1 parent 3ce4435 commit ca3a368

File tree

9 files changed

+120
-60
lines changed

9 files changed

+120
-60
lines changed

access-add-in/ACLibImportWizard.accda

4 KB
Binary file not shown.

source/ACLibImportWizardForm.frm

-41.2 KB
Binary file not shown.

source/_config_Application.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Option Compare Database
3131
Option Explicit
3232

3333
'Versionsnummer
34-
Private Const APPLICATION_VERSION As String = "1.3.1"
34+
Private Const APPLICATION_VERSION As String = "1.3.2"
3535

3636
#Const USE_CLASS_ApplicationHandler_AppFile = 1
3737
#Const USE_CLASS_ApplicationHandler_DirTextbox = 1

source/codelib/_codelib/addins/shared/ACLibConfiguration.cls

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Attribute VB_Description = "Konfigurationseinstellungen der CodeLib verwalten"
1212
' Class: _codelib.addins.shared.ACLibConfiguration
1313
'---------------------------------------------------------------------------------------
1414
'
15-
' Konfigurationseinstellungen der CodeLib verwalten
15+
' Manage AccessCodeLib configuration settings
1616
'
1717
' Author:
1818
' Josef Poetzl
@@ -44,7 +44,8 @@ Private Const EXTENSION_KEY As String = "ACLibConfiguration"
4444

4545

4646
' Grundeinstellungen
47-
Private Const ACLIB_CONFIG_ROOTFOLDERNAME As String = "AccessCodeLibrary"
47+
Private Const ACLIB_CONFIG_ROOTFOLDERNAME As String = "AccessCodeLib"
48+
Private Const ACLIB_CONFIG_ROOTFOLDERNAME_DEPR As String = "AccessCodeLibrary"
4849
Private Const ACLIB_CONFIG_DATABASENAME As String = "ACLib_Config"
4950
Private Const ACLIB_CONFIG_TABLEDEFNAME As String = "ACLib_ConfigTable"
5051

@@ -174,6 +175,7 @@ Public Property Let LocalRepositoryPath(ByVal NewPath As String)
174175

175176
End Property
176177

178+
177179
Public Property Get PrivateRepositoryPath() As String
178180

179181
If Len(m_PrivateRepositoryPath) = 0 Then
@@ -242,7 +244,7 @@ Public Property Let GitHubAuthPersonalAccessToken(ByVal NewValue As String)
242244

243245
End Property
244246

245-
Private Function GetACLibGlobalProperty(ByVal PropertyName As String) As String
247+
Friend Function GetACLibGlobalProperty(ByRef PropertyName As String) As String
246248

247249
Dim rst As DAO.Recordset
248250
Dim SelectSql As String
@@ -258,7 +260,7 @@ Private Function GetACLibGlobalProperty(ByVal PropertyName As String) As String
258260

259261
End Function
260262

261-
Private Function SetACLibGlobalProperty(ByVal PropertyName As String, ByVal NewValue As String) As String
263+
Friend Function SetACLibGlobalProperty(ByRef PropertyName As String, ByRef NewValue As String) As String
262264

263265
Dim rst As DAO.Recordset
264266
Dim SelectSql As String
@@ -342,10 +344,22 @@ Public Property Get ACLibConfigDirectory() As String
342344

343345
End Property
344346

347+
Private Property Get ACLibConfigDirectoryDepr() As String
348+
349+
Dim strPath As String
350+
351+
strPath = Environ("Appdata") & "\" & ACLIB_CONFIG_ROOTFOLDERNAME_DEPR & "\"
352+
353+
ACLibConfigDirectoryDepr = strPath
354+
355+
End Property
356+
345357
Private Property Get ACLibConfigDatabaseFile() As String
346358

347359
Dim db As DAO.Database
360+
Dim strDbFileExt As String
348361
Dim strDbFile As String
362+
Dim strDbFileDepr As String
349363
Dim bolCreateConfigTable As Boolean
350364

351365
#If ADODB_EARLYBINDING = 1 Then
@@ -354,14 +368,22 @@ Private Property Get ACLibConfigDatabaseFile() As String
354368
Dim cnn As Object
355369
#End If
356370

357-
strDbFile = CodeDb.Name
358-
strDbFile = Mid$(strDbFile, InStrRev(strDbFile, "."))
359-
If Left$(strDbFile, 5) = ".accd" Then
360-
strDbFile = ".accdu"
371+
strDbFileExt = CodeDb.Name
372+
strDbFileExt = Mid$(strDbFileExt, InStrRev(strDbFileExt, "."))
373+
If Left$(strDbFileExt, 5) = ".accd" Then
374+
strDbFileExt = ".accdu"
361375
Else
362-
strDbFile = ".mdt"
376+
strDbFileExt = ".mdt"
377+
End If
378+
strDbFile = ACLibConfigDirectory & ACLIB_CONFIG_DATABASENAME & strDbFileExt
379+
380+
' Try transfer file from deprecated folder path:
381+
If Len(Dir$(strDbFile)) = 0 Then
382+
strDbFileDepr = ACLibConfigDirectoryDepr & ACLIB_CONFIG_DATABASENAME & strDbFileExt
383+
If Len(Dir$(strDbFileDepr)) > 0 Then
384+
FileCopy strDbFileDepr, strDbFile
385+
End If
363386
End If
364-
strDbFile = ACLibConfigDirectory & ACLIB_CONFIG_DATABASENAME & strDbFile
365387

366388
If Len(Dir$(strDbFile)) = 0 Then
367389

source/codelib/_codelib/addins/shared/CodeModuleReader.cls

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,20 +276,22 @@ End Function
276276
'---------------------------------------------------------------------------------------
277277
Public Function ClassUsed(ByVal ClassName As String) As Boolean
278278

279-
Dim SearchString(5) As String
279+
Dim SearchString(6) As String
280280
Dim i As Long
281281
Dim IsUsed As Boolean
282-
Dim MaxCnt As Long
282+
Dim MaxIndex As Long
283283

284284
SearchString(0) = " As " & Trim$(ClassName) & vbNewLine
285285
SearchString(1) = " As " & Trim$(ClassName) & ","
286286
SearchString(2) = " As " & Trim$(ClassName) & " "
287287

288-
MaxCnt = 2
289-
For i = 0 To MaxCnt
290-
SearchString(MaxCnt + 1 + i) = " New " & Mid(SearchString(i), 5)
288+
MaxIndex = 2
289+
For i = 0 To MaxIndex
290+
SearchString(MaxIndex + 1 + i) = " New " & Mid(SearchString(i), 5)
291291
Next
292292

293+
SearchString(6) = " " & Trim$(ClassName) & "." ' to detect the use of static classes
294+
293295
If StrPtr(m_CodeModuleText) = 0 Then
294296
m_CodeModuleText = PlainCodeText
295297
End If
@@ -340,11 +342,11 @@ Public Function ProcedureUsed(ByRef CodeModuleProc As CodeModuleProcedure) As Bo
340342
If StrPtr(m_CodeModuleText) = 0 Then
341343
m_CodeModuleText = PlainCodeText
342344
End If
343-
345+
344346
'Text durchsuchen
345347
For i = LBound(SearchStringArray) To UBound(SearchStringArray)
346-
#If USEREGEX = 1 Then
347-
With RegEx
348+
#If USEREGEXP = 1 Then
349+
With RegExp
348350
.Pattern = SearchStringArray(i)
349351
.Global = False
350352
IsUsed = .Test(m_CodeModuleText)
@@ -395,7 +397,7 @@ Public Function HeaderItemUsed(ByRef HdrItm As CodeModuleHeaderItem) As Boolean
395397

396398
For i = LBound(SearchStringArray) To UBound(SearchStringArray)
397399
#If USEREGEX = 1 Then
398-
With RegEx
400+
With RegExp
399401
.Pattern = SearchStringArray(i)
400402
.Global = False
401403
IsUsed = .Test(m_CodeModuleText)

source/codelib/data/SqlTools.cls

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ Friend Function ConvertToNumeric(ByVal Value As Variant) As Variant
553553
Const CheckNumber As Double = 1.23
554554

555555
Dim CheckText As String
556+
Dim DecimalSeparatorToReplace As String
557+
Dim NewDecimalSeparator As String
556558

557559
If IsNull(Value) Then
558560
ConvertToNumeric = Null
@@ -564,21 +566,20 @@ Friend Function ConvertToNumeric(ByVal Value As Variant) As Variant
564566

565567
CheckText = CStr(CheckNumber)
566568
If InStr(1, CheckText, ",") > 0 Then
567-
If InStr(1, Value, ".") > 0 Then
568-
Value = Replace(Value, ".", ",")
569-
Do While Value Like "*,*,*"
570-
Value = Replace(Value, ",", vbNullString, 1, 1)
571-
Loop
572-
End If
569+
DecimalSeparatorToReplace = "."
570+
NewDecimalSeparator = ","
573571
Else
574-
If InStr(1, Value, ",") > 0 Then
575-
Value = Replace(Value, ",", ".")
576-
Do While Value Like "*.*.*"
577-
Value = Replace(Value, ".", vbNullString, 1, 1)
578-
Loop
579-
End If
572+
DecimalSeparatorToReplace = ","
573+
NewDecimalSeparator = "."
580574
End If
581575

576+
If InStr(1, Value, DecimalSeparatorToReplace) > 0 Then
577+
Value = Replace(Value, DecimalSeparatorToReplace, NewDecimalSeparator)
578+
Do While Value Like "*" & NewDecimalSeparator & "*" & NewDecimalSeparator & "*"
579+
Value = Replace(Value, NewDecimalSeparator, vbNullString, 1, 1)
580+
Loop
581+
End If
582+
582583
ConvertToNumeric = CDbl(Value)
583584

584585
End Function

source/codelib/data/dao/DaoHandler.cls

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Attribute VB_Exposed = False
2121
'---------------------------------------------------------------------------------------
2222
'<codelib>
2323
' <file>data/dao/DaoHandler.cls</file>
24-
' <description>DAO data connection methods</description>
2524
' <license>_codelib/license.bas</license>
2625
' <ref><name>DAO</name><major>5</major><minor>0</minor><guid>{00025E01-0000-0000-C000-000000000046}</guid></ref>
2726
' <test>_test/data/dao/DaoHandlerTests.cls</test>
@@ -781,21 +780,21 @@ Public Function LookupSql(ByVal SqlText As String, _
781780
Optional ByVal Index As Variant = 0&, _
782781
Optional ByVal ValueIfNull As Variant = Null) As Variant
783782

784-
Dim rst As DAO.Recordset
783+
Dim rst As DAO.Recordset
785784

786785
On Error GoTo HandleErr
787786

788-
Set rst = Me.OpenRecordset(SqlText, dbOpenForwardOnly, dbSeeChanges, dbReadOnly)
789-
With rst
790-
If .EOF Then
791-
LookupSql = ValueIfNull
792-
Else
793-
LookupSql = Nz(.Fields(Index), ValueIfNull)
794-
End If
795-
.Close
796-
End With
797-
Set rst = Nothing
798-
787+
Set rst = Me.OpenRecordset(SqlText, dbOpenForwardOnly, dbSeeChanges, dbReadOnly)
788+
With rst
789+
If .EOF Then
790+
LookupSql = ValueIfNull
791+
Else
792+
LookupSql = Nz(.Fields(Index), ValueIfNull)
793+
End If
794+
.Close
795+
End With
796+
Set rst = Nothing
797+
799798
ExitHere:
800799
Exit Function
801800

@@ -804,7 +803,7 @@ HandleErr:
804803
rst.Close
805804
Set rst = Nothing
806805
End If
807-
806+
808807
Err.Raise Err.Number, "LookupSQL:" & Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
809808

810809
End Function
@@ -829,15 +828,30 @@ Public Function Lookup(ByVal Expr As String, ByVal Domain As String, _
829828
Optional ByVal Criteria As Variant, _
830829
Optional ByVal ValueIfNull As Variant = Null) As Variant
831830

832-
Dim SelectSql As String
831+
Dim SelectSql As String
833832

834-
SelectSql = "SELECT " & Expr & " FROM (" & Domain & ")"
835-
If Not (VarType(Criteria) = vbError) Then
836-
If Len(Criteria) > 0 Then
837-
SelectSql = SelectSql & " WHERE " & Criteria
838-
End If
839-
End If
840-
Lookup = LookupSql(SelectSql, , ValueIfNull)
833+
SelectSql = BuildSelectSql(Expr, Domain, Criteria, False)
834+
Lookup = LookupSql(SelectSql, , ValueIfNull)
835+
836+
End Function
837+
838+
Private Function BuildSelectSql(ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant, _
839+
Optional ByVal Distinct As Boolean = False)
840+
841+
Dim SelectSql As String
842+
843+
SelectSql = "SELECT "
844+
If Distinct Then
845+
SelectSql = SelectSql & "Distinct "
846+
End If
847+
SelectSql = SelectSql & Expr & " FROM (" & Domain & ")"
848+
If Not (VarType(Criteria) = vbError) Then
849+
If Len(Criteria) > 0 Then
850+
SelectSql = SelectSql & " WHERE " & Criteria
851+
End If
852+
End If
853+
854+
BuildSelectSql = SelectSql
841855

842856
End Function
843857

@@ -856,8 +870,18 @@ End Function
856870
' Long
857871
'
858872
'---------------------------------------------------------------------------------------
859-
Public Function Count(ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant) As Long
860-
Count = Nz(Me.Lookup("Count(" & Expr & ")", Domain, Criteria), 0)
873+
Public Function Count(ByVal Expr As String, ByVal Domain As String, Optional ByVal Criteria As Variant, _
874+
Optional ByVal Distinct As Boolean = False) As Long
875+
876+
If Distinct Then
877+
If Expr <> "*" Then
878+
Domain = "(" & BuildSelectSql(Expr, Domain, Criteria, True) & ")"
879+
Criteria = vbNullString
880+
End If
881+
End If
882+
883+
Count = Nz(Me.Lookup("Count(" & Expr & ")", Domain, Criteria), 0)
884+
861885
End Function
862886

863887
'---------------------------------------------------------------------------------------
@@ -960,7 +984,7 @@ End Function
960984
' Works for Jet only from Jet 4.0 (Access 2000), IdentityTable is only applicable for MSSQL, under MySQL the IDENT_CURRENT function does not exist.
961985
' (<data.adodb.AdodbHandler::InsertIdentityReturn> is more suitable regarding use for active DBMS.)
962986
'---------------------------------------------------------------------------------------
963-
Public Function InsertIdentityReturn(ByVal InsertSql As String) As Variant
987+
Public Function InsertIdentityReturn(ByVal InsertSQL As String) As Variant
964988

965989
Dim db As DAO.Database
966990
Dim rst As DAO.Recordset
@@ -969,7 +993,7 @@ Public Function InsertIdentityReturn(ByVal InsertSql As String) As Variant
969993
On Error GoTo HandleErr
970994

971995
Set db = Me.CurrentDb
972-
db.Execute InsertSql
996+
db.Execute InsertSQL
973997
RecordsAffected = db.RecordsAffected
974998

975999
If RecordsAffected = 0 Then

source/codelib/data/dao/TempDbHandler.cls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@ ExitHere:
576576
HandleErr:
577577
Select Case Err.Number
578578
Case 3376 'Table does not exist.
579-
Err.Raise 123, Err.Source, Err.Description
580579
Resume ExitHere
581580
Case Else
582581
Err.Raise Err.Number, Err.Source, Err.Description

source/codelib/text/StringTools.bas

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Attribute VB_Description = "String-Hilfsfunktionen"
99
' Author:
1010
' Josef Poetzl, Sten Schmidt
1111
'
12+
' Remarks:
13+
' Use DisableReplaceVbaStringFunctions = 1 in conditional compilation arguments (in vbe project properties)
14+
' to disable replacement of VBA.Format function
15+
'
1216
'---------------------------------------------------------------------------------------
1317

1418
'---------------------------------------------------------------------------------------
@@ -124,9 +128,17 @@ End Function
124128
' String
125129
'
126130
'---------------------------------------------------------------------------------------
131+
#If DisableReplaceVbaStringFunctions = 0 Then
127132
Public Function Format(ByVal Expression As Variant, Optional ByVal FormatString As Variant, _
128133
Optional ByVal FirstDayOfWeek As VbDayOfWeek = vbSunday, _
129134
Optional ByVal FirstWeekOfYear As VbFirstWeekOfYear = vbFirstJan1) As String
135+
Format = FormatX(Expression, FormatString, FirstDayOfWeek, FirstWeekOfYear)
136+
End Function
137+
#End If
138+
139+
Public Function FormatX(ByVal Expression As Variant, Optional ByVal FormatString As Variant, _
140+
Optional ByVal FirstDayOfWeek As VbDayOfWeek = vbSunday, _
141+
Optional ByVal FirstWeekOfYear As VbFirstWeekOfYear = vbFirstJan1) As String
130142

131143
Dim Hours As Long
132144

@@ -151,7 +163,7 @@ Public Function Format(ByVal Expression As Variant, Optional ByVal FormatString
151163
End If
152164
End If
153165

154-
Format = VBA.Format$(Expression, FormatString, FirstDayOfWeek, FirstWeekOfYear)
166+
FormatX = VBA.Format$(Expression, FormatString, FirstDayOfWeek, FirstWeekOfYear)
155167

156168
End Function
157169

0 commit comments

Comments
 (0)