1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
| Option Compare Database
Private Sub Form_Load()
'lblOpenArgs.Caption = ""
' ======================================================================================
' Description : Cette routine va permettre de préparer la feuille pour qu'elle
' ressemble à une grille d'un sous-formulaire en mode feuille de donnée
'=======================================================================================
' ===== déclaration =====
Dim Spreadsheet4 As OWC11.Spreadsheet
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim intIRow As Long
Dim intICol As Long
Dim ldernlig, lderncol As Long
Dim CleBDiv, CleStep, CleSite, CleAsset As String
' ==== décomposition de l'argument transmis pour former la clé ====
CleBDiv = Split(Me.Parent.FormArgs, ";")(0)
CleStep = Split(Me.Parent.FormArgs, ";")(1)
CleSite = Split(Me.Parent.FormArgs, ";")(2)
CleAsset = Split(Me.Parent.FormArgs, ";")(3)
MsgBox ("frm_tout" & CleBDiv & CleStep & CleSite & CleAsset)
' ===== affectation =====
intIRow = 0
intICol = 0
Set Spreadsheet4 = Me.Spreadsheet4.Object
' ==== décomposition de l'argument transmis pour former la clé ====
strSql = " SELECT * FROM tbl_ReferenceCapacity WHERE RCBD = '" & CleBDiv & "' AND RCStep = '" & CleStep & "'AND RCSite = '" & CleSite & "' AND RCAsset = '" & CleAsset & "' ;"
Set rst = CurrentDb.OpenRecordset(strSql)
' ===== préparation de l'aspect =====
With Spreadsheet4
.DisplayToolbar = True ' on désactive/active la barre d'outils
With .Windows(1)
.DisplayHorizontalScrollBar = True ' on désactive/active la barre de défilement horizontale
.DisplayWorkbookTabs = True ' on désactive/active la visualisation des onglets
.DisplayColumnHeadings = True ' on désactive/active les entêtes de colonnes
.DisplayRowHeadings = True ' on désactive/active les entêtes de lignes
End With
ldernlig = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row
lderncol = .Cells(ldernlig, 1).End(xlToRight).Column
' ===== on vide la feuille =====
.ActiveSheet.Cells(1, 1).Select
.ActiveSheet.UsedRange.Clear
' ===== on fige les volets pour avoir l'entête fixe =====
.Range("A1").Select
.Windows(1).FreezePanes = True
End With
' ===== on remplit maintenant la feuille =====
With Spreadsheet4
For intICol = 1 To rst.Fields.Count - 1
' on alimente la première ligne avec le nom des champs
.Cells(1, intICol).Value = rst.Fields(intICol).Name
' mise en forme de la couleur de l'entête
.Cells(1, intICol).Interior.Color = RGB(220, 200, 250)
.Cells(1, intICol).Borders.LineStyle = xlContinuous
Next intICol
intIRow = 1
While Not rst.EOF
intIRow = intIRow + 1
For intICol = 1 To rst.Fields.Count - 1
.Cells(intIRow, intICol).Value = rst.Fields(intICol).Value
.Cells(intIRow, intICol).Borders.LineStyle = xlContinuous
Next intICol
rst.MoveNext
Wend
' ===== formatage de la feuille =====
With .Range(.Cells(1, 1), .Cells(ldernlig, lderncol))
.Columns.AutoFit
.Borders.LineStyle = xlContinuous
End With
End With
' ===== libération =====
rst.Close
Set rst = Nothing
Set Spreadsheet4 = Nothing
End Sub
Private Sub btupdate_Click()
On Error GoTo Err_btupdate_Click
MsgBox ("bouton pressé déclencher l'update")
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim ldernlig, lderncol As Long
Dim intICol, intIRow As Long
Set db = CurrentDb
Set rst = db.OpenRecordset("tbl_ReferenceCapacity", dbOpenTable)
With Spreadsheet4
MsgBox ("entree dans le with")
ldernlig = .Cells(.Cells.Rows.Count, 1).End(xlUp).Row
lderncol = .Cells(ldernlig, 1).End(xlToRight).Column
MsgBox (intIRow)
MsgBox (ldernlig)
intIRow = intIRow + 2
MsgBox (intIRow)
For intIRow = 2 To intIRow = ldernlig Step 1
MsgBox ("entree dans le for")
strSql = "UPDATE tbl_ReferenceCapacity SET RCIdletime = 20 ;"
db.Execute (strSql)
Next
End With
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
' DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
Exit_btupdate_Click:
Exit Sub
Err_btupdate_Click:
MsgBox ("err_btupdate")
MsgBox Err.Description
Resume Exit_btupdate_Click
End Sub |
Partager