Visual Basic - COMPARAR Y ACTUALIZAR DOS TABLAS

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

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.



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 Double
iniciotime = 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 False
 
 
 
porcvalcp = "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 porcvalcp
 
DoCmd.RunSQL porcvalret
 
DoCmd.RunSQL porcvalretpos
 
DoCmd.RunSQL retenido
 
DoCmd.RunSQL cedido2
 
DoCmd.RunSQL cedido1
 
DoCmd.RunSQL retenido2
DoCmd.RunSQL PrimaEx
DoCmd.RunSQL PrimaCp
DoCmd.RunSQL Primare
DoCmd.RunSQL CedidoPcpos
DoCmd.RunSQL CedidoPcneg
DoCmd.RunSQL CedidoPcret
DoCmd.RunSQL PrimaPcced
DoCmd.RunSQL PrimaPcret
DoCmd.RunSQL Cedidocp
DoCmd.RunSQL Retenidocp
DoCmd.RunSQL Primacpcp
DoCmd.RunSQL Primacpret
DoCmd.RunSQL Valoretxeq
DoCmd.RunSQL Primaretxeq
DoCmd.RunSQL Depositos
DoCmd.RunSQL ComisionMixto
DoCmd.RunSQL COSTO
DoCmd.RunSQL ComisionCp
DoCmd.RunSQL ComisionCpFs
DoCmd.RunSQL CedidoposVGde
DoCmd.RunSQL CedidonegVGde
DoCmd.RunSQL RetenidoVGde
DoCmd.RunSQL PrimacedidaVGde
DoCmd.RunSQL PrimaretVGde
DoCmd.RunSQL DepretVGde
DoCmd.RunSQL CostoretVGde
DoCmd.RunSQL Primaceddese
DoCmd.RunSQL Valorceddese
DoCmd.RunSQL Comisiondesecard
DoCmd.RunSQL Comisiondesegw
DoCmd.RunSQL Depositosdese
 
DoCmd.RunSQL CedidoVipos
DoCmd.RunSQL CedidoViret
DoCmd.RunSQL CedidoVipors
DoCmd.RunSQL PrimaViced
DoCmd.RunSQL PrimaViret
DoCmd.RunSQL ComsionVi
DoCmd.RunSQL DepretVi
DoCmd.RunSQL CostoVi
 
DoCmd.RunSQL porcvalcp142Q
DoCmd.RunSQL porcvalcp143Q
DoCmd.RunSQL porcvalmix1Q
DoCmd.RunSQL porcvalmix2Q
DoCmd.RunSQL valorcedidocp142Q
DoCmd.RunSQL valorcedidocp143Q
DoCmd.RunSQL valorcedidomix1Q
DoCmd.RunSQL valorcedidomix2Q
DoCmd.RunSQL primacedidacp142Q
DoCmd.RunSQL primacedidacp143Q
DoCmd.RunSQL primacedidamix1Q
DoCmd.RunSQL primacedidamix2Q
DoCmd.RunSQL primacedida2cp142Q
DoCmd.RunSQL primacedida2cp143Q
DoCmd.RunSQL primacedida2mix1Q
DoCmd.RunSQL primacedida2mix2Q
'DoCmd.RunSQL valorretenidocp142Q
'DoCmd.RunSQL valorretenidocp143Q
'DoCmd.RunSQL valorretenidomix1Q
'DoCmd.RunSQL valorretenidomix2Q
DoCmd.RunSQL primaretenidacp142Q
DoCmd.RunSQL primaretenidacp143Q
DoCmd.RunSQL primaretenidamix1Q
DoCmd.RunSQL primaretenidamix2Q
DoCmd.RunSQL porcretmix1Q
DoCmd.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 = Time
 
Debug.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
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder