
COMPARAR Y ACTUALIZAR DOS TABLAS
Publicado por Victor Manuel (1 intervención) el 29/05/2016 00:57:28
Cordial saludo.
Soy nuevo en el foro, y en programación.
Estoy realizando un programa para realizar una serie de cálculos de valores, acuerdo a unos limites o parámetros establecidos, por lo tanto lo realice como se muestra en el código que anexo, este código tiene problemas porque no me permite realizar comparaciones. la idea es comparar, por ejemplo el valor del campo valorasegurado de la tabla produccion en otra tabla llamada limites_contratos, la cual no he creado en acces, hasta el momento, es decir las condiciones que están después del where se debería hacer desde otra tabla (limite_contratos), y construir un bucle para realizar todos esos cálculos.
Agradezco mucho si por lo menos alguien me puede orientar como establezco mi procedimiento para armar bien este programa.
Soy nuevo en el foro, y en programación.
Estoy realizando un programa para realizar una serie de cálculos de valores, acuerdo a unos limites o parámetros establecidos, por lo tanto lo realice como se muestra en el código que anexo, este código tiene problemas porque no me permite realizar comparaciones. la idea es comparar, por ejemplo el valor del campo valorasegurado de la tabla produccion en otra tabla llamada limites_contratos, la cual no he creado en acces, hasta el momento, es decir las condiciones que están después del where se debería hacer desde otra tabla (limite_contratos), y construir un bucle para realizar todos esos cálculos.
Agradezco mucho si por lo menos alguien me puede orientar como establezco mi procedimiento para armar bien este programa.
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
Private Sub Reaseguro_Click()
Dim iniciotime As Double, fintime As Doubleiniciotime = Time'Dim contrato As String
Dim porcvalcp As String
Dim porcvalex As String
Dim porcvalret As String
Dim porcvalretpos As String
Dim retenido As String
Dim cedido1 As String
Dim cedido2 As String
Dim retenido2 As String
Dim PrimaEx As String
Dim PrimaCp As String
Dim Primare As String
Dim CedidoPcpos As String
Dim CedidoPcneg As String
Dim CedidoPcret As String
Dim PrimaPcced As String
Dim PrimaPcret As String
Dim Cedidocp As String
Dim Retenidocp As String
Dim Primacpcp As String
Dim Primacpret As String
Dim Valoretxeq As String
Dim Primaretxeq As String
Dim Depositos As String
Dim ComisionMixto As String
Dim COSTO As String
Dim ComisionCp As String
Dim ComisionCpFs As String
Dim CedidoposVGde As String
Dim CedidonegVGde As String
Dim RetenidoVGde As String
Dim PrimacedidaVGde As String
Dim PrimaretVGde As String
Dim DepretVGde As String
Dim CostoretVGde As String
Dim Primaceddese As String
Dim Valorceddese As String
Dim Comisiondesecard As String
Dim Comisiondesegw As String
Dim Depositosdese As String
Dim CedidoVipos As String
Dim CedidoViret As String
Dim CedidoVipors As String
Dim PrimaViced As String
Dim PrimaViret As String
Dim ComsionVi As String
Dim DepretVi As String
Dim CostoVi As String
Dim porcvalcp142Q As String
Dim porcvalcp143Q As String
Dim porcvalmix1Q As String
Dim porcvalmix2Q As String
Dim valorcedidocp142Q As String
Dim valorcedidocp143Q As String
Dim valorcedidomix1Q As String
Dim valorcedidomix2Q As String
Dim primacedidacp142Q As String
Dim primacedidacp143Q As String
Dim primacedidamix1Q As String
Dim primacedidamix2Q As String
Dim primacedida2cp142Q As String
Dim primacedida2cp143Q As String
Dim primacedida2mix1Q As String
Dim primacedida2mix2Q As String
Dim valorretenidocp142Q As String
Dim valorretenidocp143Q As String
Dim valorretenidomix1Q As String
Dim valorretenidomix2Q As String
Dim primaretenidacp142Q As String
Dim primaretenidacp143Q As String
Dim primaretenidamix1Q As String
Dim primaretenidamix2Q As String
Dim porcretmix1Q As String
Dim porcretmix2Q As String
Dim porcvalcpneg142Q As String
Dim porcvalcpneg143Q As String
Dim porcvalmixneg1Q As String
Dim porcvalmixneg2Q As String
Dim valorcedidonegcp142Q As String
Dim valorcedidonegcp143Q As String
Dim valorcedidonegmix1Q As String
Dim valorcedidonegmix2Q As String
DoCmd.SetWarnings Falseporcvalcp = "update Produccion set P_valor=20/100 where VALORASEGURADO>=-100000000 and VALORASEGURADO<=100000000 and CLASECONTRATO='Mixto'"
porcvalret = "update produccion set P_ret=70000000/VALORASEGURADO where P_valor=0 and CLASECONTRATO='Mixto'"
retenido = "update produccion set valorretenido=VALORASEGURADO*P_ret where CLASECONTRATO='Mixto'"
porcvalretpos = "update produccion set P_ret=P_ret*-1 where CLASECONTRATO='Mixto' and P_ret<0"
cedido2 = "update produccion set valorcedido=VALORASEGURADO*P_valor where CLASECONTRATO='Mixto'"
cedido1 = "update produccion set valorcedido=VALORASEGURADO-valorretenido where CLASECONTRATO='Mixto' and P_ret<>0"
retenido2 = "update produccion set valorretenido=VALORASEGURADO-valorcedido where CLASECONTRATO='Mixto'"
PrimaEx = "update produccion set Primacedida=prima*(1-P_ret) where CLASECONTRATO='Mixto' and P_ret<>0"
PrimaCp = "update produccion set Primacedida=prima*20/100 where CLASECONTRATO='Mixto' and P_valor<>0"
Primare = "update produccion set Primaretenida=prima-Primacedida where CLASECONTRATO='Mixto'"
CedidoPcpos = "update produccion set valorcedido=VALORASEGURADO-70000000 where VALORASEGURADO>70000000 and CLASECONTRATO='Excedente_Pc'"
CedidoPcneg = "update produccion set valorcedido=VALORASEGURADO+70000000 where VALORASEGURADO<-70000000 and CLASECONTRATO='Excedente_Pc'"
CedidoPcret = "update produccion set valorretenido=VALORASEGURADO-valorcedido where CLASECONTRATO='Excedente_Pc'"
PrimaPcced = "update produccion set Primacedida=(valorcedido*3.29/1000)/PERIODICIDADMES where CLASECONTRATO='Excedente_Pc'"
PrimaPcret = "update produccion set Primaretenida=Prima-Primacedida where CLASECONTRATO='Excedente_Pc'"
Cedidocp = "update produccion set valorcedido=VALORASEGURADO*70/100 where CLASECONTRATO='Cuota Parte'"
Retenidocp = "update produccion set valorretenido=VALORASEGURADO-valorcedido where CLASECONTRATO='Cuota Parte'"
Primacpcp = "update produccion set Primacedida=Prima*70/100 where CLASECONTRATO='Cuota Parte'"
Primacpret = "update produccion set Primaretenida=Prima-Primacedida where CLASECONTRATO='Cuota Parte'"
porcvalcp142Q = "update produccion set P_valor=2800000000/VALORASEGURADO where VALORASEGURADO>2800000000 and NoPOLIZA='3402-142' and CLASECONTRATO='Cuota Parte'"
porcvalcp143Q = "update produccion set P_valor=2800000000/VALORASEGURADO where VALORASEGURADO>2800000000 and NoPOLIZA='3402-143' and CLASECONTRATO='Cuota Parte'"
porcvalmix1Q = "update produccion set P_valor=2800000000/VALORASEGURADO where VALORASEGURADO>2800000000 and NoPOLIZA='3102-1' and CLASECONTRATO='Mixto'"
porcvalmix2Q = "update produccion set P_valor=2800000000/VALORASEGURADO where VALORASEGURADO>2800000000 and NoPOLIZA='3102-2' and CLASECONTRATO='Mixto'"
'porcvalcpneg142Q = "update produccion set P_valor=-2800000000/VALORASEGURADO where VALORASEGURADO<-2800000000 and NoPOLIZA='3402-142' and CLASECONTRATO='Cuota Parte'"
'porcvalcpneg143Q = "update produccion set P_valor=-2800000000/VALORASEGURADO where VALORASEGURADO<-2800000000 and NoPOLIZA='3402-143' and CLASECONTRATO='Cuota Parte'"
'porcvalmixneg1Q = "update produccion set P_valor=-2800000000/VALORASEGURADO where VALORASEGURADO<-2800000000 and NoPOLIZA='3102-1' and CLASECONTRATO='Mixto'"
'porcvalmixneg2Q = "update produccion set P_valor=-2800000000/VALORASEGURADO where VALORASEGURADO<-2800000000 and NoPOLIZA='3102-2' and CLASECONTRATO='Mixto'"
DoCmd.RunSQL porcvalcpDoCmd.RunSQL porcvalretDoCmd.RunSQL porcvalretposDoCmd.RunSQL retenidoDoCmd.RunSQL cedido2DoCmd.RunSQL cedido1DoCmd.RunSQL retenido2DoCmd.RunSQL PrimaExDoCmd.RunSQL PrimaCpDoCmd.RunSQL PrimareDoCmd.RunSQL CedidoPcposDoCmd.RunSQL CedidoPcnegDoCmd.RunSQL CedidoPcretDoCmd.RunSQL PrimaPccedDoCmd.RunSQL PrimaPcretDoCmd.RunSQL CedidocpDoCmd.RunSQL RetenidocpDoCmd.RunSQL PrimacpcpDoCmd.RunSQL PrimacpretDoCmd.RunSQL ValoretxeqDoCmd.RunSQL PrimaretxeqDoCmd.RunSQL DepositosDoCmd.RunSQL ComisionMixtoDoCmd.RunSQL COSTODoCmd.RunSQL ComisionCpDoCmd.RunSQL ComisionCpFsDoCmd.RunSQL CedidoposVGdeDoCmd.RunSQL CedidonegVGdeDoCmd.RunSQL RetenidoVGdeDoCmd.RunSQL PrimacedidaVGdeDoCmd.RunSQL PrimaretVGdeDoCmd.RunSQL DepretVGdeDoCmd.RunSQL CostoretVGdeDoCmd.RunSQL PrimaceddeseDoCmd.RunSQL ValorceddeseDoCmd.RunSQL ComisiondesecardDoCmd.RunSQL ComisiondesegwDoCmd.RunSQL DepositosdeseDoCmd.RunSQL CedidoViposDoCmd.RunSQL CedidoViretDoCmd.RunSQL CedidoViporsDoCmd.RunSQL PrimaVicedDoCmd.RunSQL PrimaViretDoCmd.RunSQL ComsionViDoCmd.RunSQL DepretViDoCmd.RunSQL CostoViDoCmd.RunSQL porcvalcp142QDoCmd.RunSQL porcvalcp143QDoCmd.RunSQL porcvalmix1QDoCmd.RunSQL porcvalmix2QDoCmd.RunSQL valorcedidocp142QDoCmd.RunSQL valorcedidocp143QDoCmd.RunSQL valorcedidomix1QDoCmd.RunSQL valorcedidomix2QDoCmd.RunSQL primacedidacp142QDoCmd.RunSQL primacedidacp143QDoCmd.RunSQL primacedidamix1QDoCmd.RunSQL primacedidamix2QDoCmd.RunSQL primacedida2cp142QDoCmd.RunSQL primacedida2cp143QDoCmd.RunSQL primacedida2mix1QDoCmd.RunSQL primacedida2mix2Q'DoCmd.RunSQL valorretenidocp142Q
'DoCmd.RunSQL valorretenidocp143Q
'DoCmd.RunSQL valorretenidomix1Q
'DoCmd.RunSQL valorretenidomix2Q
DoCmd.RunSQL primaretenidacp142QDoCmd.RunSQL primaretenidacp143QDoCmd.RunSQL primaretenidamix1QDoCmd.RunSQL primaretenidamix2QDoCmd.RunSQL porcretmix1QDoCmd.RunSQL porcretmix2Q'DoCmd.RunSQL porcvalcpneg142Q
'DoCmd.RunSQL porcvalcpneg143Q
'DoCmd.RunSQL porcvalmixneg1Q
'DoCmd.RunSQL porcvalmixneg2Q
'DoCmd.RunSQL valorcedidonegcp142Q
'DoCmd.RunSQL valorcedidonegcp143Q
'DoCmd.RunSQL valorcedidonegmix1Q
'DoCmd.RunSQL valorcedidonegmix2Q
fintime = TimeDebug.Print "Tiempo de ejecucion:", fintime - iniciotime
MsgBox "Tiempo de Ejecucion Segundos: " + Format$(fintime - iniciotime)
'MsgBox "Execution time in seconds: " + Format$(EndTime - StartTime)
'MsgBox "Execution time in seconds: " + Format$(EndTime - StartTime)
End Sub
Valora esta pregunta


0
