Voici mon projet , j'utilise un menu général sous format switchboard . Le tout fonctionne bien , Mais je doit maintenant rendre ma base de données disponible en français et en anglais . J'ai copier mon Menu général ( qui utilise le switchboard ) et j'ai modifié le code . Le tout fonctionne asser rondement , cependant j'ai un problème dans le menu de la version anglaise , lorsque je clique sur l'option modifier les éléments du menu général , les informations qui apparait sont ceux de mon menu francais . Et lorsque je fait un test et que je change une information dans cette option il change l'info sur mon menu francais sans changer celle de mon menu anglais . Pourtant si je vais changer l'information directement dans ma table switchboard items_eng celui ci change l'info seulement dans le bon menu . il doit y avoir une option qui m'échape dans le code de mon menu en anglais . Alors si vous avez une idée n'hésitez pas !
Merci
Les informations de mon menu français .
Formulaire Menu Général
Table Switchboard Items
Les informations de mon menu français .
Formulaire Main Menu
Table Switchboard Items_eng
Voici le code de mon menu en anglais ( L'erreur doit ce trouver dans ce code )
Et voici mon code du menu en français . ( celui ci fonctione parfaitement )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218 Option Compare Database Private Sub Form_Open(Cancel As Integer) ' Minimize the database window and initialize the form. On Error GoTo Form_Open_Err ' Minimize the database window. DoCmd.SelectObject acForm, "Main Menu", True DoCmd.Minimize ' Move to the switchboard page that is marked as the default. Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Par défaut' " Me.FilterOn = True Form_Open_Exit: Exit Sub Form_Open_Err: MsgBox Err.Description Resume Form_Open_Exit End Sub Private Sub Form_Current() ' Update the caption and fill in the list of options. Me.Caption = Nz(Me![ItemText], "") FillOptions End Sub Private Sub FillOptions() ' Fill in the options for this switchboard page. ' The number of buttons on the form. Const conNumButtons = 8 Dim con As Object Dim rs As Object Dim stSql As String Dim intOption As Integer ' Set the focus to the first button on the form, ' and then hide all of the buttons on the form ' but the first. You can't hide the field with the focus. Me![Option1].SetFocus For intOption = 2 To conNumButtons Me("Option" & intOption).Visible = False Me("OptionLabel" & intOption).Visible = False Next intOption ' Open the table of Switchboard Items, and find ' the first item for this Switchboard Page. Set con = Application.CurrentProject.Connection stSql = "SELECT * FROM [Switchboard Items_eng]" stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID] stSql = stSql & " ORDER BY [ItemNumber];" Set rs = CreateObject("ADODB.Recordset") rs.Open stSql, con, 1 ' 1 = adOpenKeyset ' If there are no options for this Switchboard Page, ' display a message. Otherwise, fill the page with the items. If (rs.EOF) Then Me![OptionLabel1].Caption = "Il n'y a aucun élément pour cette page de Menu Général" Else While (Not (rs.EOF)) Me("Option" & rs![ItemNumber]).Visible = True Me("OptionLabel" & rs![ItemNumber]).Visible = True Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText] rs.MoveNext Wend End If ' Close the recordset and the database. rs.Close Set rs = Nothing Set con = Nothing End Sub Private Function HandleButtonClick(intBtn As Integer) ' This function is called when a button is clicked. ' intBtn indicates which button was clicked. ' Constants for the commands that can be executed. Const conCmdGotoSwitchboard = 1 Const conCmdOpenFormAdd = 2 Const conCmdOpenFormBrowse = 3 Const conCmdOpenReport = 4 Const conCmdCustomizeSwitchboard = 5 Const conCmdExitApplication = 6 Const conCmdRunMacro = 7 Const conCmdRunCode = 8 Const conCmdOpenPage = 9 ' An error that is special cased. Const conErrDoCmdCancelled = 2501 Dim con As Object Dim rs As Object Dim stSql As String On Error GoTo HandleButtonClick_Err ' Find the item in the Switchboard Items table ' that corresponds to the button that was clicked. Set con = Application.CurrentProject.Connection Set rs = CreateObject("ADODB.Recordset") stSql = "SELECT * FROM [Switchboard items_eng] " stSql = stSql & "WHERE [SwitchboardID]=" & Me![SwitchboardID] & " AND [ItemNumber]=" & intBtn rs.Open stSql, con, 1 ' 1 = adOpenKeyset ' If no item matches, report the error and exit the function. If (rs.EOF) Then MsgBox "Une erreur s'est produite lors de la lecture de la table d'élément du Menu général." rs.Close Set rs = Nothing Set con = Nothing Exit Function End If Select Case rs![Command] ' Go to another switchboard. Case conCmdGotoSwitchboard Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument] ' Open a form in Add mode. Case conCmdOpenFormAdd DoCmd.OpenForm rs![Argument], , , , acAdd ' Open a form. Case conCmdOpenFormBrowse DoCmd.OpenForm rs![Argument] ' Open a report. Case conCmdOpenReport DoCmd.OpenReport rs![Argument], acPreview ' Customize the Switchboard. Case conCmdCustomizeSwitchboard ' Handle the case where the Switchboard Manager ' is not installed (e.g. Minimal Install). On Error Resume Next Application.Run "ACWZMAIN.sbm_Entry" If (Err <> 0) Then MsgBox "Commande non disponible." On Error GoTo 0 ' Update the form. Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Par défaut' " Me.Caption = Nz(Me![ItemText], "") FillOptions ' Exit the application. Case conCmdExitApplication CloseCurrentDatabase ' Run a macro. Case conCmdRunMacro DoCmd.RunMacro rs![Argument] ' Run code. Case conCmdRunCode Application.Run rs![Argument] ' Open a Data Access Page Case conCmdOpenPage DoCmd.OpenDataAccessPage rs![Argument] ' Any other command is unrecognized. Case Else MsgBox "Option inconnue." End Select ' Close the recordset and the database. rs.Close HandleButtonClick_Exit: On Error Resume Next Set rs = Nothing Set con = Nothing Exit Function HandleButtonClick_Err: ' If the action was cancelled by the user for ' some reason, don't display an error message. ' Instead, resume on the next line. If (Err = conErrDoCmdCancelled) Then Resume Next Else MsgBox "Une erreur s'est produite lors de l'exécution de la commande.", vbCritical Resume HandleButtonClick_Exit End If End Function Private Sub Form_Timer() Me.txthorloge = "Welcome - We are the " & Date & " time is " & Time() End Sub Private Sub B_open_Click() On Error GoTo Err_B_open_Click DoCmd.Close Dim stDocName As String Dim stLinkCriteria As String stDocName = "Menu Général" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_B_open_Click: Exit Sub Err_B_open_Click: MsgBox Err.Description Resume Exit_B_open_Click End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218 Option Compare Database Private Sub Form_Open(Cancel As Integer) ' Minimize the database window and initialize the form. On Error GoTo Form_Open_Err ' Minimize the database window. DoCmd.SelectObject acForm, "Menu Général*", True DoCmd.Minimize ' Move to the switchboard page that is marked as the default. Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Par défaut' " Me.FilterOn = True Form_Open_Exit: Exit Sub Form_Open_Err: MsgBox Err.Description Resume Form_Open_Exit End Sub Private Sub Form_Current() ' Update the caption and fill in the list of options. Me.Caption = Nz(Me![ItemText], "") FillOptions End Sub Private Sub FillOptions() ' Fill in the options for this switchboard page. ' The number of buttons on the form. Const conNumButtons = 8 Dim con As Object Dim rs As Object Dim stSql As String Dim intOption As Integer ' Set the focus to the first button on the form, ' and then hide all of the buttons on the form ' but the first. You can't hide the field with the focus. Me![Option1].SetFocus For intOption = 2 To conNumButtons Me("Option" & intOption).Visible = False Me("OptionLabel" & intOption).Visible = False Next intOption ' Open the table of Switchboard Items, and find ' the first item for this Switchboard Page. Set con = Application.CurrentProject.Connection stSql = "SELECT * FROM [Switchboard Items]" stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID] stSql = stSql & " ORDER BY [ItemNumber];" Set rs = CreateObject("ADODB.Recordset") rs.Open stSql, con, 1 ' 1 = adOpenKeyset ' If there are no options for this Switchboard Page, ' display a message. Otherwise, fill the page with the items. If (rs.EOF) Then Me![OptionLabel1].Caption = "Il n'y a aucun élément pour cette page de Menu Général" Else While (Not (rs.EOF)) Me("Option" & rs![ItemNumber]).Visible = True Me("OptionLabel" & rs![ItemNumber]).Visible = True Me("OptionLabel" & rs![ItemNumber]).Caption = rs![ItemText] rs.MoveNext Wend End If ' Close the recordset and the database. rs.Close Set rs = Nothing Set con = Nothing End Sub Private Function HandleButtonClick(intBtn As Integer) ' This function is called when a button is clicked. ' intBtn indicates which button was clicked. ' Constants for the commands that can be executed. Const conCmdGotoSwitchboard = 1 Const conCmdOpenFormAdd = 2 Const conCmdOpenFormBrowse = 3 Const conCmdOpenReport = 4 Const conCmdCustomizeSwitchboard = 5 Const conCmdExitApplication = 6 Const conCmdRunMacro = 7 Const conCmdRunCode = 8 Const conCmdOpenPage = 9 ' An error that is special cased. Const conErrDoCmdCancelled = 2501 Dim con As Object Dim rs As Object Dim stSql As String On Error GoTo HandleButtonClick_Err ' Find the item in the Switchboard Items table ' that corresponds to the button that was clicked. Set con = Application.CurrentProject.Connection Set rs = CreateObject("ADODB.Recordset") stSql = "SELECT * FROM [Switchboard Items] " stSql = stSql & "WHERE [SwitchboardID]=" & Me![SwitchboardID] & " AND [ItemNumber]=" & intBtn rs.Open stSql, con, 1 ' 1 = adOpenKeyset ' If no item matches, report the error and exit the function. If (rs.EOF) Then MsgBox "Une erreur s'est produite lors de la lecture de la table d'élément du Menu général." rs.Close Set rs = Nothing Set con = Nothing Exit Function End If Select Case rs![Command] ' Go to another switchboard. Case conCmdGotoSwitchboard Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument] ' Open a form in Add mode. Case conCmdOpenFormAdd DoCmd.OpenForm rs![Argument], , , , acAdd ' Open a form. Case conCmdOpenFormBrowse DoCmd.OpenForm rs![Argument] ' Open a report. Case conCmdOpenReport DoCmd.OpenReport rs![Argument], acPreview ' Customize the Switchboard. Case conCmdCustomizeSwitchboard ' Handle the case where the Switchboard Manager ' is not installed (e.g. Minimal Install). On Error Resume Next Application.Run "ACWZMAIN.sbm_Entry" If (Err <> 0) Then MsgBox "Commande non disponible." On Error GoTo 0 ' Update the form. Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Par défaut' " Me.Caption = Nz(Me![ItemText], "") FillOptions ' Exit the application. Case conCmdExitApplication CloseCurrentDatabase ' Run a macro. Case conCmdRunMacro DoCmd.RunMacro rs![Argument] ' Run code. Case conCmdRunCode Application.Run rs![Argument] ' Open a Data Access Page Case conCmdOpenPage DoCmd.OpenDataAccessPage rs![Argument] ' Any other command is unrecognized. Case Else MsgBox "Option inconnue." End Select ' Close the recordset and the database. rs.Close HandleButtonClick_Exit: On Error Resume Next Set rs = Nothing Set con = Nothing Exit Function HandleButtonClick_Err: ' If the action was cancelled by the user for ' some reason, don't display an error message. ' Instead, resume on the next line. If (Err = conErrDoCmdCancelled) Then Resume Next Else MsgBox "Une erreur s'est produite lors de l'exécution de la commande.", vbCritical Resume HandleButtonClick_Exit End If End Function Private Sub Form_Timer() Me.txthorloge = "Bienvenue - Nous sommes le " & Date & " et il est " & Time() End Sub Private Sub B_open_Click() On Error GoTo Err_B_open_Click DoCmd.Close Dim stDocName As String Dim stLinkCriteria As String stDocName = "Main Menu" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_B_open_Click: Exit Sub Err_B_open_Click: MsgBox Err.Description Resume Exit_B_open_Click End Sub
Partager