Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/02/2011, 12:01
RoyMalcolm
 
Fecha de Ingreso: junio-2010
Ubicación: maracaibo
Mensajes: 40
Antigüedad: 13 años, 10 meses
Puntos: 0
De acuerdo como hacer para guardar y editar

hola amigos saludos de antemano se me presenta la siguiente situacion

tengo un formulario de proveedores el cual puedo ingresar, eliminar y editar

ciertamete estas funciones las hace correctamente el problema es q lo codifique en cada boton correspondiente a cada una des estas acciones.

me gustaria que me brindaran su ayuda y diganme por favor
como pordira hacer para que en un boton de guardar pueda identificar cuando se
esta ingresando un registro nuevo para que ejecute la accion de ingresar y cuando se esta editando el registro ya existente.

los codigos son los siguientes

para guardar;

Private Sub cmdGuardar_Click()
strSQL = "INSERT INTO tblProveedor (TipoRif, NumRif, Nombre, NctaContab, pctRetenIVA, PctRetenISLR, Direccion, " & _
"Ciudad, Estado, Pais, CodigoPostal, Telefono1, Telefono2, Email, PaginaWeb, Observaciones) " & _
"VALUES ('" & cmbTipoRif.Text & "', '" & txtNumRif.Text & "', '" & txtNombreProv.Text & "', " & _
"'" & txtNumCtaContab & "', '" & txtPctReteIVA & "', '" & txtPctReteISLR & "', '" & txtDireccion & "', " & _
"'" & txtCiudad.Text & "', '" & txtEstado.Text & "', '" & txtPais.Text & "', '" & txtCodPostal.Text & "', " & _
"'" & txtTelefono1.Text & "', '" & txtTelefono2.Text & "', '" & txtEmail.Text & "', '" & txtPaginaWeb.Text & "', " & _
"'" & txtObservaciones.Text & "')"
strTipRif = cmbTipoRif.Text
strProvRif = txtNumRif.Text

cnConexionBD.Execute (strSQL)
MsgBox "Datos Guardatos Exitosamente", vbInformation
Call proConsulta
rsProveedor.Find "NumRif LIKE '%" & strProvRif & "%'", , adSearchForward
Call Asigna_Campos
Call proActivaBotones
end sub

para editar es:

Private Sub cmdEditar_Click()
strSQL = "UPDATE tblProveedor " & _
"SET Nombre = '" & txtNombreProv.Text & "', NctaContab = '" & txtNumCtaContab & "', PctRetenIva = '" & txtPctReteIVA & "', " & _
"PctRetenISLR = '" & txtPctReteISLR & "', Direccion = '" & txtDireccion & "', Ciudad = '" & txtCiudad.Text & "', " & _
"Estado = '" & txtEstado.Text & "', Pais = '" & txtPais.Text & "', CodigoPostal = '" & txtCodPostal.Text & "', " & _
"Telefono1 = '" & txtTelefono1.Text & "', Telefono2 = '" & txtTelefono2.Text & "', Email = '" & txtEmail.Text & "', " & _
"PaginaWeb = '" & txtPaginaWeb.Text & "', Observaciones = '" & txtObservaciones.Text & "' " & _
"WHERE TipoRif = '" & cmbTipoRif.Text & "' and NumRif = '" & txtNumRif.Text & "' "
strTipRif = cmbTipoRif.Text
strProvRif = txtNumRif.Text
cnConexionBD.Execute (strSQL)
MsgBox "Datos Editados Exitosamente", vbInformation
Call proConsulta
rsProveedor.Find "NumRif LIKE '%" & strProvRif & "%'", , adSearchForward 'ubicando el registro editado
Call Asigna_Campos
End Sub