Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gitattributes template for Microsoft Access database source files
# gitattributes template for Microsoft Access database source files
# Website: https://github.com/joyfullservice/msaccess-vcs-addin
#

Expand All @@ -13,11 +13,22 @@

# The local VCS index file is paired with the binary database file
# and should not be comitted to version control.
vcs-index.json
vcs-index.*

# Ignore any dotenv files (used for external database connections)
*.env
logs/
test-results/
.env.*
!.env*.example

# Ignore log files generated by the VCS Add-in
# Comment out the following line if you wish to include log files in git.
*.log

# others
*.dll
*.zip

# don't commit dict files in this repository
*.accd[ab].DeclarationDict.txt
6 changes: 4 additions & 2 deletions Example_APIusage.accdb.src/modules/_LoadAddIn.bas
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ Option Explicit

Public Sub LoadAddIn()

'API: RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean = False)
'API: Public Function RunVcsCheck(Optional ByVal OpenDialogToFixLettercase As Boolean = False, _
' Optional ByVal DeclDictFilePath As String = vbNullString, _
' Optional ByVal IncludeUsedMembers As Boolean = False) As Variant

Dim AddInCallPath As String
AddInCallPath = CurrentProject.Path & "\ACLibDeclarationDictCore.RunVcsCheck"

Dim Result As Variant
Result = Application.Run(AddInCallPath, True)
Result = Application.Run(AddInCallPath, True, vbNullString, True)
If Result = True Then
Debug.Print "No problems with letter case"
Else
Expand Down
2 changes: 1 addition & 1 deletion Example_APIusage.accdb.src/vcs-options.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Info": {
"AddinVersion": "4.1.2",
"AddinVersion": "4.1.3",
"AccessVersion": "16.0 64-bit"
},
"Options": {
Expand Down
50 changes: 41 additions & 9 deletions Tests/ACLibDeclarationDictCore/DeclarationDictTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ Public Sub ImportCode_InsertCodeLine_CheckKeys(ByVal Code As String, ByVal Expec

Dim Actual As String

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
'm_DeclDict.ImportCode Code
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -73,7 +76,9 @@ Public Sub ImportCode_Issue4_MultiDimArrayDeclaration(ByVal Code As String, ByVa

Dim Actual As String

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -89,7 +94,9 @@ Public Sub ImportCode_InsertCodeLines_CheckKeys(ByVal Code As String, ByVal Expe

Dim Actual As String

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -101,7 +108,9 @@ Public Sub ImportCode_Issue3_RemovingCommentCorruptsLineEndings(ByVal Code As St

Dim Actual As String

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -114,7 +123,9 @@ Public Sub ImportCode_Pullrequest8_LineLabel(ByVal Code As String, ByVal Expecte

Dim Actual As String

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -135,7 +146,9 @@ Public Sub ImportCode_API_CheckKeys(ByVal Code As String, ByVal Expected As Stri
' RegEx.Pattern = "(?:Declare)\s(Function|Sub)\s([^ ]*)[^(]*\("
' Actual = RegEx.Replace(Code, "$1 $2(")

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -156,7 +169,9 @@ Public Sub ImportCode_EnumCode_CheckKeys()

Const Expected As String = "xyz|en1|en2|x|y"

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand All @@ -177,7 +192,9 @@ Public Sub ImportCode_TypeCode_CheckKeys()

Const Expected As String = "xyz|F1|F2|x|y"

m_DeclDict.ImportCode Code
With New CodemoduleDeclarationReader
.ImportCode Code, m_DeclDict
End With
Actual = Join(m_DeclDict.WordsDict.Keys, "|")

Assert.That Actual, Iz.EqualTo(Expected)
Expand Down Expand Up @@ -211,7 +228,9 @@ Public Sub ImportClassCodeModule_CheckKeysExists()
"TestPullrequest8_LineLabels", "ExitHere", "ErrHandler")


m_DeclDict.ImportVBComponent CurrentVbProject.VBComponents("DeclarationDictTestCodemodule")
With New CodemoduleDeclarationReader
.ImportVBComponent CurrentVbProject.VBComponents("DeclarationDictTestCodemodule"), m_DeclDict
End With

Set ActualDict = m_DeclDict.WordsDict

Expand All @@ -224,3 +243,16 @@ Public Sub ImportClassCodeModule_CheckKeysExists()

End Sub

Public Sub ToString_AddWords_OutputVariations()

m_DeclDict.AddWord "Test"
m_DeclDict.AddWord "test"
m_DeclDict.AddWord "xyz"
m_DeclDict.AddWord "xyz"

Dim Actual As String
Actual = m_DeclDict.ToString(False)

Assert.That Actual, Iz.EqualTo("Test:Test|test")

End Sub
99 changes: 99 additions & 0 deletions source/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# AGENTS.md - Working With Exported Microsoft Access Source Files

This folder is a Microsoft Access database exported to text files by the MSAccess
VCS add-in. Editing these files is how you change the database, but edits only
take effect when the add-in imports them back in Access. You cannot run or test
this code directly, and the add-in is required to build a working database from it.

This file and everything under `vcs-agent-docs/` are generated by the add-in and
**rewritten on every export**. Keep your own project notes elsewhere.

## Non-negotiable rules

1. **Do not change file encoding.** Source files are UTF-8, and most are UTF-8
*with BOM* (bytes `EF BB BF`). Re-saving without the BOM makes import fail or
silently corrupt the object.
2. **Do not change line endings.** Access `LoadFromText` requires CRLF (`\r\n`).
3. **Do not edit** `vcs-index.idx` (binary change index), `.frx` files (binary OLE
data), or `.thmx` files (ZIP archives — edit the extracted contents instead).
4. **Do not rename a file** without changing the object name stored inside it.
File names must match object names exactly.
5. **Do not alter VBA scaffolding:** `Attribute VB_Name` lines, the
`VERSION`/`BEGIN`/`END` block at the top of a `.cls`, or module-level
`Attribute VB_*` lines. The code below them is yours to edit.

## Which file do I edit?

| To change | Edit | Read first |
|---|---|---|
| VBA in a standard module | `modules/<name>.bas` | `vcs-agent-docs/vba-modules.md` |
| VBA in a class module | `modules/<name>.cls` | `vcs-agent-docs/vba-modules.md` |
| Form or report code-behind | `forms/<name>.cls`, `reports/<name>.cls` | `vcs-agent-docs/vba-modules.md` |
| Form or report layout | `forms/<name>.form`, `reports/<name>.report` | `vcs-agent-docs/forms-reports.md` |
| Conditional formatting rules | the form's or report's companion `.json` | `vcs-agent-docs/forms-reports.md` |
| Query logic | `queries/<name>.sql` — the sole source of truth for SQL | `vcs-agent-docs/queries.md` |
| Query properties or design layout | `queries/<name>.json` | `vcs-agent-docs/queries.md` |
| A macro | `macros/<name>.macro` | — |
| A table definition | `tbldefs/<name>.xml` and `.json` | — |
| A connection string | `.env` at this folder's root (gitignored) | `vcs-agent-docs/troubleshooting.md` |
| Tests | a test module under `modules/` | `vcs-agent-docs/testing.md` |

Export format 5.0.0 renamed several object types from the overloaded `.bas`
extension: forms to `.form`, reports to `.report`, macros to `.macro`, and queries
to `.sql` plus `.json`. Older projects still use `.bas` for these, so check which
extensions are actually present. Import accepts both.

## File placement follows the `@Folder` annotation

The add-in reads Rubberduck-style `'@Folder("Category")` annotations and exports
components into matching subdirectories, with dots as path separators:
`'@Folder("Components.ADP")` lands in `modules/Components/ADP/`. Components with no
annotation stay at the root of `modules/`, `forms/`, or `reports/`. Import scans
subdirectories recursively.

**The annotation decides where the file belongs on disk, not the folder you happen
to be editing in.** This is the most common way agents corrupt a project:

- For modules, the annotation is in the `.bas` or `.cls` itself. For forms and
reports it lives in the `.cls` code-behind only — not in `.form`/`.report`,
`.json`, or `.svg`.
- Before creating or moving a component, search the **entire** `modules/`, `forms/`,
or `reports/` tree for an existing file with the same base name (for modules,
match on `Attribute VB_Name`). Edit that file in place rather than creating a
second copy elsewhere.
- If two copies exist, such as `modules/modFoo.bas` and `modules/Tests/modFoo.bas`,
build imports **both** and the last one silently wins. No error is shown.
- Build removes a misplaced duplicate automatically when exactly one copy sits in
its annotation-derived folder. Ambiguous cases are left alone with a warning.
Removing a duplicate form or report deletes its whole source group together
(`.form`/`.report` plus `.cls`, `.json`, and `.svg`).

To relocate a component, change its `'@Folder` annotation and let the next export
move the file.

## Where the details live

Each of these is short. Read the matching one before making that kind of change.

| File | Read it before |
|---|---|
| `vcs-agent-docs/vba-modules.md` | Editing any `.bas` or `.cls`, or adding a member attribute |
| `vcs-agent-docs/forms-reports.md` | Editing a `.form` or `.report` layout, or conditional formatting |
| `vcs-agent-docs/queries.md` | Editing anything in `queries/` |
| `vcs-agent-docs/testing.md` | Writing, running, or filtering tests |
| `vcs-agent-docs/troubleshooting.md` | An import, build, or compile failed, or you need the log files |

## How changes get back into Access

Ask the user to run a **merge build** from the add-in ribbon, which imports changed
source files into the existing database. A **full build** creates a new database
from source instead, and **export** goes the other way, writing database objects
out to these files. When a source file and its database object have both changed,
the add-in detects the conflict and prompts the user to choose which version wins.

## More information

- [MSAccess VCS Add-in](https://github.com/joyfullservice/msaccess-vcs-addin)
- [Wiki: Export-Import File Types](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Export-Import-File-Types)
- [Wiki: Supported Objects](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Supported-Objects)
- [Wiki: Options](https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Options)
4 changes: 2 additions & 2 deletions source/dbs-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"Type": 4
},
"NavPane Width": {
"Value": 678,
"Value": 540,
"Type": 4
},
"Never Cache": {
Expand Down Expand Up @@ -205,7 +205,7 @@
"Type": 2
},
"Version": {
"Value": "14.0",
"Value": "12.0",
"Type": 12
},
"WebDesignMode": {
Expand Down
20 changes: 16 additions & 4 deletions source/documents.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
"Items": {
"Databases": {
"SummaryInfo": {
"Author": "Josef Pötzl",
"Comments": "* List of declarations\r\n* Save to / load from table or file\r\n* Compare and repair letter case",
"Company": "access-codelib.net",
"Title": "ACLib Declaration Dictionary"
"Author": {
"Type": 10,
"Value": "Josef Pötzl"
},
"Comments": {
"Type": 10,
"Value": "* List of declarations\r\n* Save to / load from table or file\r\n* Compare and repair letter case"
},
"Company": {
"Type": 10,
"Value": "access-codelib.net"
},
"Title": {
"Type": 10,
"Value": "ACLib Declaration Dictionary"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/forms/DeclarationDictApiDialog.cls
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Private Sub RefreshDiffData()
Else
With Me.lbDictData
Set .Recordset = m_WordListRecordset
.Value = Me.lbDictData.Column(0, 0)
.Value = .Column(0, Abs(.ColumnHeads))
End With
FillWordVariationsList
End If
Expand Down
Loading
Loading