- Export 7 VBA modules as .bas files in src/ - Add form button helper functions (GoToNewRecord, DeleteCurrentRecord, SaveAndNew) - Export frm_Accueil form definition as text 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
213 lines
8.5 KiB
QBasic
213 lines
8.5 KiB
QBasic
Attribute VB_Name = "mod_FormBuilder"
|
|
Option Compare Database
|
|
Option Explicit
|
|
|
|
'===============================================================================
|
|
' Module: mod_FormBuilder
|
|
' Description: Creation programmatique des formulaires
|
|
' Auteur: Alexis Trouve
|
|
' Date: 2025-12-30
|
|
'===============================================================================
|
|
|
|
Private Const acLabel As Integer = 100
|
|
Private Const acTextBox As Integer = 109
|
|
Private Const acComboBox As Integer = 111
|
|
Private Const acCommandButton As Integer = 104
|
|
Private Const acDetail As Integer = 0
|
|
Private Const acHeader As Integer = 1
|
|
|
|
Public Sub BuildAllForms()
|
|
On Error GoTo ErrHandler
|
|
BuildFormAccueil
|
|
BuildFormClients
|
|
BuildFormProjets
|
|
BuildFormSaisieTemps
|
|
BuildFormHistorique
|
|
MsgBox "Formulaires crees avec succes!", vbInformation
|
|
Exit Sub
|
|
ErrHandler:
|
|
MsgBox "Erreur: " & Err.Description, vbCritical
|
|
End Sub
|
|
|
|
Public Sub BuildFormAccueil()
|
|
On Error GoTo ErrHandler
|
|
Dim frm As Form, ctl As Control
|
|
On Error Resume Next
|
|
DoCmd.DeleteObject acForm, "frm_Accueil"
|
|
On Error GoTo ErrHandler
|
|
Set frm = CreateForm()
|
|
frm.Caption = "TimeTrack Pro"
|
|
frm.RecordSelectors = False
|
|
frm.NavigationButtons = False
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 500, 300, 5000, 500)
|
|
ctl.Caption = "TimeTrack Pro"
|
|
ctl.FontSize = 20
|
|
ctl.FontBold = True
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 1200, 2200, 500)
|
|
ctl.Caption = "Clients"
|
|
ctl.OnClick = "=OpenFormClients()"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 1900, 2200, 500)
|
|
ctl.Caption = "Projets"
|
|
ctl.OnClick = "=OpenFormProjets()"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 2600, 2200, 500)
|
|
ctl.Caption = "Saisie Temps"
|
|
ctl.OnClick = "=OpenFormSaisieTemps()"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 500, 3300, 2200, 500)
|
|
ctl.Caption = "Historique"
|
|
ctl.OnClick = "=OpenFormHistorique()"
|
|
DoCmd.Close acForm, frm.Name, acSaveYes
|
|
DoCmd.Rename "frm_Accueil", acForm, frm.Name
|
|
Exit Sub
|
|
ErrHandler:
|
|
MsgBox "Erreur Accueil: " & Err.Description, vbCritical
|
|
End Sub
|
|
|
|
Public Sub BuildFormClients()
|
|
On Error GoTo ErrHandler
|
|
Dim frm As Form, ctl As Control
|
|
On Error Resume Next
|
|
DoCmd.DeleteObject acForm, "frm_Clients"
|
|
On Error GoTo ErrHandler
|
|
Set frm = CreateForm()
|
|
frm.RecordSource = "tbl_Clients"
|
|
frm.Caption = "Clients"
|
|
frm.NavigationButtons = True
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 200, 1200, 250)
|
|
ctl.Caption = "Nom:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 200, 3500, 250)
|
|
ctl.ControlSource = "Nom"
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 550, 1200, 250)
|
|
ctl.Caption = "Email:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 550, 3500, 250)
|
|
ctl.ControlSource = "Email"
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 900, 1200, 250)
|
|
ctl.Caption = "Tel:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 900, 2000, 250)
|
|
ctl.ControlSource = "Telephone"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 200, 1400, 1500, 400)
|
|
ctl.Caption = "Nouveau"
|
|
ctl.OnClick = "=GoToNewRecord()"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 1900, 1400, 1500, 400)
|
|
ctl.Caption = "Retour"
|
|
ctl.OnClick = "=OpenFormAccueil()"
|
|
DoCmd.Close acForm, frm.Name, acSaveYes
|
|
DoCmd.Rename "frm_Clients", acForm, frm.Name
|
|
Exit Sub
|
|
ErrHandler:
|
|
MsgBox "Erreur Clients: " & Err.Description, vbCritical
|
|
End Sub
|
|
|
|
Public Sub BuildFormProjets()
|
|
On Error GoTo ErrHandler
|
|
Dim frm As Form, ctl As Control
|
|
On Error Resume Next
|
|
DoCmd.DeleteObject acForm, "frm_Projets"
|
|
On Error GoTo ErrHandler
|
|
Set frm = CreateForm()
|
|
frm.RecordSource = "tbl_Projets"
|
|
frm.Caption = "Projets"
|
|
frm.NavigationButtons = True
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 200, 1200, 250)
|
|
ctl.Caption = "Client:"
|
|
Set ctl = CreateControl(frm.Name, acComboBox, acDetail, , , 1500, 200, 3000, 250)
|
|
ctl.ControlSource = "ClientID"
|
|
ctl.RowSource = "SELECT ClientID, Nom FROM tbl_Clients"
|
|
ctl.ColumnCount = 2
|
|
ctl.ColumnWidths = "0;2500"
|
|
ctl.BoundColumn = 1
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 550, 1200, 250)
|
|
ctl.Caption = "Nom:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 550, 3000, 250)
|
|
ctl.ControlSource = "Nom"
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 900, 1200, 250)
|
|
ctl.Caption = "Taux:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 900, 1500, 250)
|
|
ctl.ControlSource = "TauxHoraire"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 200, 1400, 1500, 400)
|
|
ctl.Caption = "Nouveau"
|
|
ctl.OnClick = "=GoToNewRecord()"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 1900, 1400, 1500, 400)
|
|
ctl.Caption = "Retour"
|
|
ctl.OnClick = "=OpenFormAccueil()"
|
|
DoCmd.Close acForm, frm.Name, acSaveYes
|
|
DoCmd.Rename "frm_Projets", acForm, frm.Name
|
|
Exit Sub
|
|
ErrHandler:
|
|
MsgBox "Erreur Projets: " & Err.Description, vbCritical
|
|
End Sub
|
|
|
|
Public Sub BuildFormSaisieTemps()
|
|
On Error GoTo ErrHandler
|
|
Dim frm As Form, ctl As Control
|
|
On Error Resume Next
|
|
DoCmd.DeleteObject acForm, "frm_SaisieTemps"
|
|
On Error GoTo ErrHandler
|
|
Set frm = CreateForm()
|
|
frm.RecordSource = "tbl_Temps"
|
|
frm.Caption = "Saisie Temps"
|
|
frm.NavigationButtons = True
|
|
frm.DataEntry = True
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 200, 1200, 250)
|
|
ctl.Caption = "Projet:"
|
|
Set ctl = CreateControl(frm.Name, acComboBox, acDetail, , , 1500, 200, 4000, 250)
|
|
ctl.ControlSource = "ProjetID"
|
|
ctl.RowSource = "SELECT ProjetID, Nom FROM tbl_Projets WHERE Actif=True"
|
|
ctl.ColumnCount = 2
|
|
ctl.ColumnWidths = "0;3500"
|
|
ctl.BoundColumn = 1
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 550, 1200, 250)
|
|
ctl.Caption = "Date:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 550, 1800, 250)
|
|
ctl.ControlSource = "Date"
|
|
ctl.DefaultValue = "=Date()"
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 900, 1200, 250)
|
|
ctl.Caption = "Duree:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 900, 1000, 250)
|
|
ctl.ControlSource = "Duree"
|
|
Set ctl = CreateControl(frm.Name, acLabel, acDetail, , , 200, 1250, 1200, 250)
|
|
ctl.Caption = "Notes:"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1500, 1250, 4000, 600)
|
|
ctl.ControlSource = "Description"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 200, 2000, 1500, 400)
|
|
ctl.Caption = "Enregistrer"
|
|
ctl.OnClick = "=SaveAndNew()"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acDetail, , , 1900, 2000, 1500, 400)
|
|
ctl.Caption = "Retour"
|
|
ctl.OnClick = "=OpenFormAccueil()"
|
|
DoCmd.Close acForm, frm.Name, acSaveYes
|
|
DoCmd.Rename "frm_SaisieTemps", acForm, frm.Name
|
|
Exit Sub
|
|
ErrHandler:
|
|
MsgBox "Erreur Saisie: " & Err.Description, vbCritical
|
|
End Sub
|
|
|
|
Public Sub BuildFormHistorique()
|
|
On Error GoTo ErrHandler
|
|
Dim frm As Form, ctl As Control
|
|
On Error Resume Next
|
|
DoCmd.DeleteObject acForm, "frm_Historique"
|
|
On Error GoTo ErrHandler
|
|
Set frm = CreateForm()
|
|
frm.RecordSource = "SELECT t.*, p.Nom AS Projet, c.Nom AS Client FROM (tbl_Temps t INNER JOIN tbl_Projets p ON t.ProjetID=p.ProjetID) INNER JOIN tbl_Clients c ON p.ClientID=c.ClientID"
|
|
frm.Caption = "Historique"
|
|
frm.DefaultView = 2
|
|
frm.AllowEdits = False
|
|
frm.AllowAdditions = False
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 100, 100, 1500, 250)
|
|
ctl.ControlSource = "Client"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 1700, 100, 1500, 250)
|
|
ctl.ControlSource = "Projet"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 3300, 100, 1200, 250)
|
|
ctl.ControlSource = "Date"
|
|
Set ctl = CreateControl(frm.Name, acTextBox, acDetail, , , 4600, 100, 800, 250)
|
|
ctl.ControlSource = "Duree"
|
|
Set ctl = CreateControl(frm.Name, acCommandButton, acHeader, , , 200, 200, 1500, 400)
|
|
ctl.Caption = "Retour"
|
|
ctl.OnClick = "=OpenFormAccueil()"
|
|
DoCmd.Close acForm, frm.Name, acSaveYes
|
|
DoCmd.Rename "frm_Historique", acForm, frm.Name
|
|
Exit Sub
|
|
ErrHandler:
|
|
MsgBox "Erreur Historique: " & Err.Description, vbCritical
|
|
End Sub
|