timetrack-pro/scripts/modules/mod_FormBuilder.bas
StillHammer a485651273 Phase 5: Form generator script + import guide
- Add mod_FormBuilder.bas to generate 5 forms programmatically
- Add IMPORT_FORMS.md with step-by-step instructions
- Update PLAN.md and README.md with new progress
- Created 5 empty forms via MCP (to be populated by script)

Run BuildAllForms() in Access VBA to create form controls.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:51:25 +07:00

447 lines
14 KiB
QBasic

Attribute VB_Name = "mod_FormBuilder"
Option Compare Database
Option Explicit
' ============================================
' mod_FormBuilder - Generateur de formulaires
' Execute BuildAllForms() pour creer les forms
' ============================================
Public Sub BuildAllForms()
On Error GoTo ErrHandler
BuildFormAccueil
BuildFormClients
BuildFormProjets
BuildFormSaisieTemps
BuildFormHistorique
MsgBox "Tous les formulaires ont ete crees!", vbInformation, "TimeTrack Pro"
Exit Sub
ErrHandler:
MsgBox "Erreur: " & Err.Description, vbCritical, "Erreur"
End Sub
Public Sub BuildFormAccueil()
Dim frm As Form, ctl As Control
On Error Resume Next
DoCmd.DeleteObject acForm, "frm_Accueil"
On Error GoTo 0
Set frm = CreateForm()
frm.Caption = "TimeTrack Pro - Accueil"
frm.RecordSelectors = False
frm.NavigationButtons = False
frm.ScrollBars = 0
frm.Width = 7000
frm.Section(0).Height = 5000
' Titre
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 500, 300, 5500, 600)
ctl.Caption = "TimeTrack Pro"
ctl.FontSize = 24
ctl.FontBold = True
ctl.ForeColor = RGB(0, 102, 204)
ctl.Name = "lblTitre"
' Sous-titre
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 500, 950, 5000, 350)
ctl.Caption = "Gestionnaire de temps professionnel"
ctl.FontSize = 11
ctl.FontItalic = True
ctl.ForeColor = RGB(100, 100, 100)
ctl.Name = "lblSousTitre"
' Bouton Clients
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 1700, 2500, 550)
ctl.Caption = "Gerer les Clients"
ctl.Name = "btnClients"
ctl.OnClick = "=OpenFormClients()"
' Bouton Projets
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 2450, 2500, 550)
ctl.Caption = "Gerer les Projets"
ctl.Name = "btnProjets"
ctl.OnClick = "=OpenFormProjets()"
' Bouton Saisie
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 3200, 2500, 550)
ctl.Caption = "Saisir du Temps"
ctl.Name = "btnSaisie"
ctl.OnClick = "=OpenFormSaisieTemps()"
' Bouton Historique
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 3950, 2500, 550)
ctl.Caption = "Voir l'Historique"
ctl.Name = "btnHistorique"
ctl.OnClick = "=OpenFormHistorique()"
' Stats
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 3800, 1700, 1500, 300)
ctl.Caption = "Clients:"
ctl.FontBold = True
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 5300, 1700, 1200, 300)
ctl.ControlSource = "=DCount('*','tbl_Clients')"
ctl.Name = "txtStatClients"
ctl.Enabled = False
ctl.Locked = True
ctl.BackStyle = 0
ctl.BorderStyle = 0
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 3800, 2100, 1500, 300)
ctl.Caption = "Projets:"
ctl.FontBold = True
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 5300, 2100, 1200, 300)
ctl.ControlSource = "=DCount('*','tbl_Projets','Actif=True')"
ctl.Name = "txtStatProjets"
ctl.Enabled = False
ctl.Locked = True
ctl.BackStyle = 0
ctl.BorderStyle = 0
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 3800, 2500, 1500, 300)
ctl.Caption = "Heures:"
ctl.FontBold = True
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 5300, 2500, 1200, 300)
ctl.ControlSource = "=Nz(DSum('Duree','tbl_Temps'),0)"
ctl.Name = "txtStatHeures"
ctl.Enabled = False
ctl.Locked = True
ctl.BackStyle = 0
ctl.BorderStyle = 0
ctl.Format = "0.0"
DoCmd.Close acForm, frm.Name, acSaveYes
DoCmd.Rename "frm_Accueil", acForm, frm.Name
End Sub
Public Sub BuildFormClients()
Dim frm As Form, ctl As Control
On Error Resume Next
DoCmd.DeleteObject acForm, "frm_Clients"
On Error GoTo 0
Set frm = CreateForm()
frm.RecordSource = "tbl_Clients"
frm.Caption = "Gestion des Clients"
frm.DefaultView = 0
frm.NavigationButtons = True
frm.RecordSelectors = True
' Header
frm.Section(acHeader).Visible = True
frm.Section(acHeader).Height = 550
Set ctl = CreateControl(frm.Name, acLabel, acHeader, , , 200, 120, 4000, 350)
ctl.Caption = "Gestion des Clients"
ctl.FontSize = 14
ctl.FontBold = True
ctl.Name = "lblHeader"
' Champs
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 150, 1400, 280)
ctl.Caption = "ID Client:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 150, 1000, 280)
ctl.ControlSource = "ClientID"
ctl.Name = "txtClientID"
ctl.Enabled = False
ctl.Locked = True
ctl.TabStop = False
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 520, 1400, 280)
ctl.Caption = "Nom:*"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 520, 4000, 280)
ctl.ControlSource = "Nom"
ctl.Name = "txtNom"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 890, 1400, 280)
ctl.Caption = "Email:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 890, 4000, 280)
ctl.ControlSource = "Email"
ctl.Name = "txtEmail"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 1260, 1400, 280)
ctl.Caption = "Telephone:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 1260, 2500, 280)
ctl.ControlSource = "Telephone"
ctl.Name = "txtTelephone"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 1630, 1400, 280)
ctl.Caption = "Notes:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 1630, 4000, 700)
ctl.ControlSource = "Notes"
ctl.Name = "txtNotes"
' Boutons
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 200, 2500, 1700, 450)
ctl.Caption = "Nouveau"
ctl.Name = "btnNouveau"
ctl.OnClick = "=GoToNewRecord()"
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 2000, 2500, 1700, 450)
ctl.Caption = "Supprimer"
ctl.Name = "btnSupprimer"
ctl.OnClick = "=DeleteCurrentRecord()"
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 3800, 2500, 1900, 450)
ctl.Caption = "Retour Accueil"
ctl.Name = "btnRetour"
ctl.OnClick = "=OpenFormAccueil()"
DoCmd.Close acForm, frm.Name, acSaveYes
DoCmd.Rename "frm_Clients", acForm, frm.Name
End Sub
Public Sub BuildFormProjets()
Dim frm As Form, ctl As Control
On Error Resume Next
DoCmd.DeleteObject acForm, "frm_Projets"
On Error GoTo 0
Set frm = CreateForm()
frm.RecordSource = "tbl_Projets"
frm.Caption = "Gestion des Projets"
frm.DefaultView = 0
frm.NavigationButtons = True
' Header
frm.Section(acHeader).Visible = True
frm.Section(acHeader).Height = 550
Set ctl = CreateControl(frm.Name, acLabel, acHeader, , , 200, 120, 4000, 350)
ctl.Caption = "Gestion des Projets"
ctl.FontSize = 14
ctl.FontBold = True
' Champs
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 150, 1400, 280)
ctl.Caption = "ID Projet:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 150, 1000, 280)
ctl.ControlSource = "ProjetID"
ctl.Enabled = False
ctl.Locked = True
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 520, 1400, 280)
ctl.Caption = "Client:*"
Set ctl = CreateControl(frm.Name, acComboBox, acDetail, , , 1700, 520, 4000, 280)
ctl.ControlSource = "ClientID"
ctl.RowSource = "SELECT ClientID, Nom FROM tbl_Clients ORDER BY Nom"
ctl.ColumnCount = 2
ctl.ColumnWidths = "0;3800"
ctl.BoundColumn = 1
ctl.Name = "cboClient"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 890, 1400, 280)
ctl.Caption = "Nom projet:*"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 890, 4000, 280)
ctl.ControlSource = "Nom"
ctl.Name = "txtNom"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 1260, 1400, 280)
ctl.Caption = "Taux horaire:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 1260, 1500, 280)
ctl.ControlSource = "TauxHoraire"
ctl.Format = "Currency"
ctl.Name = "txtTaux"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 1630, 1400, 280)
ctl.Caption = "Actif:"
Set ctl = CreateControl(frm.Name, acCheckBox, acDetail, , , 1700, 1630, 400, 280)
ctl.ControlSource = "Actif"
ctl.Name = "chkActif"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 2000, 1400, 280)
ctl.Caption = "Description:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 2000, 4000, 700)
ctl.ControlSource = "Description"
ctl.Name = "txtDescription"
' Boutons
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 200, 2850, 1700, 450)
ctl.Caption = "Nouveau"
ctl.OnClick = "=GoToNewRecord()"
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 2000, 2850, 1700, 450)
ctl.Caption = "Supprimer"
ctl.OnClick = "=DeleteCurrentRecord()"
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 3800, 2850, 1900, 450)
ctl.Caption = "Retour Accueil"
ctl.OnClick = "=OpenFormAccueil()"
DoCmd.Close acForm, frm.Name, acSaveYes
DoCmd.Rename "frm_Projets", acForm, frm.Name
End Sub
Public Sub BuildFormSaisieTemps()
Dim frm As Form, ctl As Control
On Error Resume Next
DoCmd.DeleteObject acForm, "frm_SaisieTemps"
On Error GoTo 0
Set frm = CreateForm()
frm.RecordSource = "tbl_Temps"
frm.Caption = "Saisie du Temps"
frm.DefaultView = 0
frm.NavigationButtons = True
frm.DataEntry = True
' Header
frm.Section(acHeader).Visible = True
frm.Section(acHeader).Height = 550
Set ctl = CreateControl(frm.Name, acLabel, acHeader, , , 200, 120, 4000, 350)
ctl.Caption = "Saisie du Temps"
ctl.FontSize = 14
ctl.FontBold = True
' Champs
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 150, 1400, 280)
ctl.Caption = "Projet:*"
Set ctl = CreateControl(frm.Name, acComboBox, acDetail, , , 1700, 150, 4500, 280)
ctl.ControlSource = "ProjetID"
ctl.RowSource = "SELECT p.ProjetID, c.Nom & ' - ' & p.Nom AS Projet FROM tbl_Projets p INNER JOIN tbl_Clients c ON p.ClientID = c.ClientID WHERE p.Actif=True ORDER BY c.Nom, p.Nom"
ctl.ColumnCount = 2
ctl.ColumnWidths = "0;4300"
ctl.BoundColumn = 1
ctl.Name = "cboProjet"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 550, 1400, 280)
ctl.Caption = "Date:*"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 550, 2000, 280)
ctl.ControlSource = "Date"
ctl.Format = "Short Date"
ctl.DefaultValue = "=Date()"
ctl.Name = "txtDate"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 950, 1400, 280)
ctl.Caption = "Duree (h):*"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 950, 1200, 280)
ctl.ControlSource = "Duree"
ctl.Format = "0.00"
ctl.Name = "txtDuree"
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 1350, 1400, 280)
ctl.Caption = "Description:"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 1350, 4500, 900)
ctl.ControlSource = "Description"
ctl.Name = "txtDescription"
' Boutons
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 200, 2400, 2200, 500)
ctl.Caption = "Enregistrer + Nouveau"
ctl.Name = "btnSauver"
ctl.OnClick = "=SaveAndNew()"
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 2600, 2400, 1800, 500)
ctl.Caption = "Historique"
ctl.Name = "btnHistorique"
ctl.OnClick = "=OpenFormHistorique()"
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 4600, 2400, 1600, 500)
ctl.Caption = "Accueil"
ctl.Name = "btnRetour"
ctl.OnClick = "=OpenFormAccueil()"
DoCmd.Close acForm, frm.Name, acSaveYes
DoCmd.Rename "frm_SaisieTemps", acForm, frm.Name
End Sub
Public Sub BuildFormHistorique()
Dim frm As Form, ctl As Control
Dim strSQL As String
On Error Resume Next
DoCmd.DeleteObject acForm, "frm_Historique"
On Error GoTo 0
strSQL = "SELECT t.TempsID, c.Nom AS Client, p.Nom AS Projet, t.Date, t.Duree, " & _
"t.Duree*p.TauxHoraire AS Montant, t.Description " & _
"FROM (tbl_Temps t INNER JOIN tbl_Projets p ON t.ProjetID=p.ProjetID) " & _
"INNER JOIN tbl_Clients c ON p.ClientID=c.ClientID ORDER BY t.Date DESC"
Set frm = CreateForm()
frm.RecordSource = strSQL
frm.Caption = "Historique des Temps"
frm.DefaultView = 2
frm.AllowEdits = False
frm.AllowAdditions = False
frm.AllowDeletions = False
' Header
frm.Section(acHeader).Visible = True
frm.Section(acHeader).Height = 900
Set ctl = CreateControl(frm.Name, acLabel, acHeader, , , 200, 80, 4000, 350)
ctl.Caption = "Historique des Temps"
ctl.FontSize = 14
ctl.FontBold = True
Set ctl = CreateControl(frm.Name, acCommandButton, acHeader, , , 200, 500, 1800, 350)
ctl.Caption = "Saisir Temps"
ctl.OnClick = "=OpenFormSaisieTemps()"
Set ctl = CreateControl(frm.Name, acCommandButton, acHeader, , , 2100, 500, 1800, 350)
ctl.Caption = "Accueil"
ctl.OnClick = "=OpenFormAccueil()"
Set ctl = CreateControl(frm.Name, acLabel, acHeader, , , 4200, 500, 1200, 350)
ctl.Caption = "Total heures:"
ctl.FontBold = True
Set ctl = CreateControl(frm.Name, acTextBox, acHeader, , , 5400, 500, 1200, 350)
ctl.ControlSource = "=Nz(DSum('Duree','tbl_Temps'),0)"
ctl.Format = "0.00"
ctl.Enabled = False
ctl.BackStyle = 0
ctl.BorderStyle = 0
' Colonnes detail
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 100, 50, 1400, 250)
ctl.ControlSource = "Client"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1600, 50, 1400, 250)
ctl.ControlSource = "Projet"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 3100, 50, 1100, 250)
ctl.ControlSource = "Date"
ctl.Format = "Short Date"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 4300, 50, 700, 250)
ctl.ControlSource = "Duree"
ctl.Format = "0.00"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 5100, 50, 1100, 250)
ctl.ControlSource = "Montant"
ctl.Format = "Currency"
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 6300, 50, 2500, 250)
ctl.ControlSource = "Description"
DoCmd.Close acForm, frm.Name, acSaveYes
DoCmd.Rename "frm_Historique", acForm, frm.Name
End Sub