
se limpia el datagrid de un form al abrir otro form.
Publicado por Azeddine (3 intervenciones) el 14/01/2015 17:52:14
Hola a todos.
Después de darle mil vueltas recurro a ustedes a ver si me pueden ayudar.
Tengo dos formularios. CrearForm y ModificarForm. Ambos llevan un datagrid: grillaregistros.
Los forms por separado funcionan a la perfección, el problema resulta cuando:
A) Si abro CrearForm, luego ModificarForm, al volver a CrearForm me encuentro que eldatagrid esta completamente vacio(nada, ni campos ni el formatoque aplique , nada).
B) lo mismo pero al reves..... Si abro ModificarForm, luego CrearForm , al volver a ModificarForm me encuentro que eldatagrid esta completamente vacio.
El caso es que en el form modificar al hacer clic me selecciona el registro a modificar, pero si se me vacia me da el error de que "conjunto de filas no esta disponible".
Mencionar que accedo a estos formularios desde los menús de un formulario MDI, y que si cierro los forms y vuelvo abrir funciona perfectamente, no se si se trata de alguna propiedad del grid pero no se exactamente donde puede estar el problema. Muchas gracias de antemano. Un saludo.
Después de darle mil vueltas recurro a ustedes a ver si me pueden ayudar.
Tengo dos formularios. CrearForm y ModificarForm. Ambos llevan un datagrid: grillaregistros.
Los forms por separado funcionan a la perfección, el problema resulta cuando:
A) Si abro CrearForm, luego ModificarForm, al volver a CrearForm me encuentro que eldatagrid esta completamente vacio(nada, ni campos ni el formatoque aplique , nada).
B) lo mismo pero al reves..... Si abro ModificarForm, luego CrearForm , al volver a ModificarForm me encuentro que eldatagrid esta completamente vacio.
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
''''''''CODIGO FORM CREAR''''''
Private Sub ccmdReestablecer_Click()
LIMPIAR
End Sub
Private Sub cmdCerrar_Click()
Unload Me
End Sub
Private Sub cmdCrear_Click()
If txtNombre.Text = "" Then MsgBox "El campo GRUPO no puede estar vacio", vbInformation, "Aviso": txtNombre.SetFocus: Exit Sub
If txtInt1.Text = "" Then MsgBox "El campo Integrante 1 no puede estar vacio", vbInformation, "Aviso": txtInt1.SetFocus: Exit Sub
If txtInt2.Text = "" Then MsgBox "El campo Integrante 2 no puede estar vacio", vbInformation, "Aviso": txtInt2.SetFocus: Exit Sub
If txtInt3.Text = "" Then MsgBox "El campo Integrante 3 no puede estar vacio.En caso de que solo haya dos miembros en el grupo ponga un punto.", vbInformation, "Aviso": txtInt3.SetFocus: Exit Sub
With RsRegistros
.Requery
.AddNew
!grupo = txtNombre.Text
!fecha = DTPicker1.Value
!integrante1 = txtInt1.Text
!integrante2 = txtInt2.Text
!integrante3 = txtInt3.Text
.Update
.Requery
LIMPIAR
End With
FormatoGrillaRegistros
MsgBox " GRUPO CREADO", vbInformation, ""
Unload Me
End Sub
Private Sub Form_Load()
Skin1.LoadSkin App.Path & "\skin.skn" ''''' CARGAMOS EL SKIN
Skin1.ApplySkin RegistrosForm.hWnd '''''APLICAMOS EL SKIN A NUESTRO FORMULARIO
REGISTROS
DATOS
Set GrillaRegistros.DataSource = RsRegistros
FormatoGrillaRegistros
BLOQUEAR
End Sub
Sub LIMPIAR()
txtNombre.Text = ""
DTPicker1.Value = Date
txtInt1.Text = ""
txtInt2.Text = ""
txtInt3.Text = ""
txtNombre.SetFocus
End Sub
Sub FormatoGrillaRegistros()
With RsRegistros
GrillaRegistros.Columns(0).Width = 0
GrillaRegistros.Columns(1).Width = 2000
GrillaRegistros.Columns(2).Width = 1000
GrillaRegistros.Columns(3).Width = 3500
GrillaRegistros.Columns(4).Width = 3500
GrillaRegistros.Columns(5).Width = 3500
End With
End Sub
Sub BLOQUEAR()
GrillaRegistros.AllowUpdate = False
End Sub
''''''''CODIGO FORM MODIFICAR''''''
Private Sub ccmdReestablecer_Click()
LIMPIAR
End Sub
Private Sub cmdModificar_Click()
If lblIdregistros.Caption = "" Then MsgBox "Selecciona un Grupo a modificar", vbInformation, "Aviso": Exit Sub
If txtNombre.Text = "" Then MsgBox "El campo nombre no puede estar vacio", vbInformation, "Aviso": txtNombre.SetFocus: Exit Sub
If txtInt1.Text = "" Then MsgBox "El campo Integrante 1 no puede estar vacio", vbInformation, "Aviso": txtInt1.SetFocus: Exit Sub
If txtInt2.Text = "" Then MsgBox "El campo Integrante 2 no puede estar vacio", vbInformation, "Aviso": txtInt2.SetFocus: Exit Sub
If txtInt3.Text = "" Then MsgBox "El campo Integrante 3 no puede estar vacio.En caso de que solo haya dos miembros en el grupo ponga un punto.", vbInformation, "Aviso": txtInt3.SetFocus: Exit Sub
With RsRegistros
.Requery
.Find "IdRegistros='" & Val(lblIdregistros.Caption) & "'"
!grupo = txtNombre.Text
!fecha = DTPicker1.Value
!integrante1 = txtInt1.Text
!integrante2 = txtInt2.Text
!integrante3 = txtInt3.Text
.UpdateBatch
.Requery
LIMPIAR
BLOQUEAR
End With
FormatoGrillaRegistros
MsgBox " GRUPO MODIFICADO", vbInformation, ""
Unload Me
End Sub
Private Sub Form_Load()
Skin1.LoadSkin App.Path & "\skin.skn" ''''' CARGAMOS EL SKIN
Skin1.ApplySkin ModificarRegistrosForm.hWnd '''''APLICAMOS EL SKIN A NUESTRO FORMULARIO
REGISTROS
DATOS
Set GrillaRegistros.DataSource = RsRegistros
FormatoGrillaRegistros
BLOQUEAR
GrillaRegistros.AllowUpdate = False
End Sub
Sub FormatoGrillaRegistros()
With RsRegistros
GrillaRegistros.Columns(0).Width = 0
GrillaRegistros.Columns(1).Width = 2000
GrillaRegistros.Columns(2).Width = 1000
GrillaRegistros.Columns(3).Width = 3500
GrillaRegistros.Columns(4).Width = 3500
GrillaRegistros.Columns(5).Width = 3500
End With
End Sub
Private Sub GrillaRegistros_Click()
With RsRegistros
If .BOF Or .EOF Then Exit Sub
.Find "IdRegistros='" & Val(GrillaRegistros.Columns(0).Text) & "'"
lblIdregistros.Caption = !IdRegistros
txtNombre.Text = !grupo
DTPicker1.Value = !fecha
txtInt1.Text = !integrante1
txtInt2.Text = !integrante2
txtInt3.Text = !integrante3
DESBLOQUEAR
'lblCodigo.Caption = !IdRegistros
End With
End Sub
Sub LIMPIAR()
txtNombre.Text = ""
DTPicker1.Value = Date
txtInt1.Text = ""
txtInt2.Text = ""
txtInt3.Text = ""
txtNombre.SetFocus
End Sub
Sub BLOQUEAR()
txtNombre.Locked = True
txtInt1.Locked = True
txtInt2.Locked = True
txtInt3.Locked = True
DTPicker1.Enabled = False
End Sub
Sub DESBLOQUEAR()
txtNombre.Locked = False
txtInt1.Locked = False
txtInt2.Locked = False
txtInt3.Locked = False
DTPicker1.Enabled = True
End Sub
El caso es que en el form modificar al hacer clic me selecciona el registro a modificar, pero si se me vacia me da el error de que "conjunto de filas no esta disponible".
Mencionar que accedo a estos formularios desde los menús de un formulario MDI, y que si cierro los forms y vuelvo abrir funciona perfectamente, no se si se trata de alguna propiedad del grid pero no se exactamente donde puede estar el problema. Muchas gracias de antemano. Un saludo.
Valora esta pregunta


0