que dificil se me hace esto pero ahi terca yo en aprender......pues ahi va mi problem......: usando ado utilice varias tablas para hacer mi consulta en un data grid y ahora desea agregar, modificar y eliminar (pero solo eliminar aparentemente por medio de una llave q se llamara estado donde 0 sera estado activo y 1 estado eliminado) ....hasta ahora voy avanzando esto pero ya me tranque y todo me sale a medias
ojala alguien pueda ayudarme a terminar esto y principalmente a entenderlo..gracias de antemano
Dim RstPec As New ADODB.Recordset
Dim Temp As New ADODB.Recordset
Dim sql As String
Dim RstNuevo As New ADODB.Recordset
Option Explicit
Private Sub CmdEAnular_Click()
End Sub
Private Sub Command1_Click()
Dim pru As Integer
If RstPec.RecordCount = 1 Then
RstPec.MoveFirst
Do While Not RstPec.EOF
RstPec.Delete
RstPec.MoveNext
Loop
Me.TxtCodProducto.SetFocus
Me.TxtSubTotal.Text = ""
Me.TxtTotal.Text = ""
Exit Sub
End If
If RstPec.RecordCount > 0 Then
If RstPec.BOF Or RstPec.EOF Then
MsgBox "Selecccionar un Registro para Eliminar"
Else
pru = RstPec!NUMERO
RstPec.Delete adAffectCurrent
End If
End If
End Sub
Private Sub Command2_Click()
Picture2.Visible = True
TxtAreaOrigen.Enabled = False
TxtArea.Enabled = True
TxtSubArea.Enabled = True
TxtUarea.Enabled = True
TxtCodAreaDestino.Enabled = False
TxtAreaDestino.Enabled = True
TxtSubareaDestino.Enabled = True
TxtUareaDestino.Enabled = True
TxtCodProducto.Enabled = True
TxtPartida.Enabled = True
TxtDescripcion.Enabled = True
TxtUnidad.Enabled = True
TxtCantidad.Enabled = True
TxtPrecio.Enabled = True
TxtSubTotal.Enabled = True
TxtStock.Enabled = True
TxtTotal.Enabled = True
If Command2.Caption = "&Grabar" Then
Command2.Caption = "&Modificar"
Call Modo("M")
Call Activa(False)
MsgBox "SE MODIFICO CON EXITO ..!", vbExclamation
Command1.Enabled = True
ElseIf Command2.Caption = "&Modificar" Then
Command2.Caption = "&Grabar"
Activa (True)
Command1.Enabled = False
End If
Refrescar
Debug.Print sql
DbPrin.Execute sql
RstPec.Requery
Else
If Command2.Caption = "&Modificar" Then
Command2.Caption = "&Grabar"
Activa (True)
End If
Refrescar
End If
End Sub
Public Sub Modo(Gm As String)
DbPrin.Execute "Execute MANTEPECOSABIEN '" & Gm & "','" & TxtArea & "','" & TxtAreaOrigen & "','" & TxtArea & "','" & TxtUarea & "'"
End Sub
Public Sub Refrescar()
Command1.Refresh
Command2.Refresh
Command3.Refresh
End Sub
Public Sub Activa(TF As Boolean)
TxtArea.Enabled = TF
TxtSubArea.Enabled = TF
TxtUarea.Enabled = TF
TxtAreaDestino.Enabled = TF
TxtSubareaDestino.Enabled = TF
TxtUareaDestino.Enabled = TF
TxtCodProducto.Enabled = TF
TxtPartida.Enabled = TF
TxtDescripcion.Enabled = TF
TxtUnidad.Enabled = TF
TxtCantidad.Enabled = TF
TxtPrecio.Enabled = TF
TxtSubTotal.Enabled = TF
TxtStock.Enabled = TF
TxtTotal.Enabled = TF
End Sub
Private Sub Command3_Click()
Unload Me
End
End Sub
Private Sub DgEdicion_Click()
If RstPec.RecordCount > 0 Then
TxtAreaOrigen = RstPec(1)
TxtArea = RstPec(2)
TxtSubArea = RstPec(3)
TxtUarea = RstPec(4)
TxtCodAreaDestino = RstPec(5)
TxtAreaDestino = RstPec(6)
TxtSubareaDestino = RstPec(7)
TxtUareaDestino = RstPec(8)
TxtCodProducto = RstPec(9)
TxtPartida = RstPec(10)
TxtDescripcion = RstPec(11)
TxtUnidad = RstPec(12)
TxtCantidad = RstPec(13)
TxtPrecio = RstPec(14)
TxtSubTotal = RstPec(15)
TxtStock = RstPec(16)
TxtTotal = RstPec(15)
End If
End Sub
Private Sub Form_Load()
Dim sql As String
FrmPassword.Mascar.ApplySkin Me.hwnd
Me.Top = 50
Me.Left = 1150
Picture1.BackColor = RGB(210, 218, 227)
Picture2.BackColor = RGB(210, 218, 227)
Label1.BackColor = RGB(210, 218, 227)
Label2.BackColor = RGB(210, 218, 227)
Label3.BackColor = RGB(210, 218, 227)
Label4.BackColor = RGB(210, 218, 227)
Label5.BackColor = RGB(210, 218, 227)
Label6.BackColor = RGB(210, 218, 227)
Dim RstNuevo As New ADODB.Recordset
Me.TxtUsuario = UserActive
Me.TxtFechMod = Date
sql = "SELECT right(('000'+convert(nvarchar,CODTAB)),2)+' '+DESCRIPCION as opcion FROM MODALIDAD"
AsignaRst RstNuevo, sql, DbPrin
CmbModalidad.AddItem "Seleccionar Opcion"
Do While Not RstNuevo.EOF
CmbModalidad.AddItem RstNuevo!opcion
RstNuevo.MoveNext
Loop
CmbModalidad.ListIndex = 0
sql = "SELECT DOCUMENTO.NUMERO, dbo.CAB_SALIDA.CODAREAO, AREAS_1.AREA AS AREA_ORIGEN, AREAS_1.SUBAREA AS SUB_AREA_ORIGEN, " & _
"AREAS_1.U_AREA AS U_AREA_ORIGEN, dbo.CAB_SALIDA.CODAREAD, dbo.AREAS.AREA AS AREA_D, dbo.AREAS.SUBAREA AS SUBAREA_D, " & _
"dbo.AREAS.U_AREA AS U_AREA_D, dbo.DET_SALIDA.COD AS CODBIEN, dbo.BIEN.PARTIDA, dbo.BIEN.DESCRIPCION, dbo.BIEN.UNIDAD, " & _
"dbo.DET_SALIDA.CANTIDAD, dbo.DET_SALIDA.PRECIO, dbo.DET_SALIDA.CANTIDAD * dbo.DET_SALIDA.PRECIO AS SUBTOTAL, " & _
"dbo.DET_SALIDA.STOCK_ALDIA AS STOCK, dbo.CAB_SALIDA.FECHMOD, dbo.CAB_SALIDA.USERMOD, dbo.CAB_SALIDA.FECHA, " & _
"dbo.MODALIDAD.DESCRIPCION AS MODALIDAD " & _
"FROM CAB_SALIDA INNER JOIN " & _
"dbo.DET_SALIDA ON dbo.CAB_SALIDA.IDSALIDA = dbo.DET_SALIDA.IDSALIDA INNER JOIN " & _
"dbo.DOCUMENTO ON dbo.CAB_SALIDA.IDSALIDA = dbo.DOCUMENTO.IDSALIDA INNER JOIN " & _
"dbo.AREAS ON dbo.CAB_SALIDA.CODAREAD = dbo.AREAS.CODAREA INNER JOIN " & _
"dbo.AREAS AREAS_1 ON dbo.CAB_SALIDA.CODAREAO = AREAS_1.CODAREA INNER JOIN " & _
"dbo.BIEN ON dbo.DET_SALIDA.COD = dbo.BIEN.COD INNER JOIN " & _
"dbo.MODALIDAD ON dbo.CAB_SALIDA.MODALIDAD = dbo.MODALIDAD.CodTab WHERE(dbo.CAB_SALIDA.ESTADO = '0')AND (dbo.DOCUMENTO.ANO_TRAB = '2006') ORDER BY dbo.DOCUMENTO.NUMERO "
Debug.Print sql
AsignaRst RstPec, sql, DbPrin
If RstPec.RecordCount > 0 Then
Set Me.DgEdicion.DataSource = RstPec
Else
MsgBox "No existe ninguna Pecosa!!"
End If
End Sub
Private Sub TxtEBusca_Change()
sql = "SELECT DOCUMENTO.NUMERO, dbo.CAB_SALIDA.CODAREAO, AREAS_1.AREA AS AREA_ORIGEN, AREAS_1.SUBAREA AS SUB_AREA_ORIGEN, " & _
"AREAS_1.U_AREA AS U_AREA_ORIGEN, dbo.CAB_SALIDA.CODAREAD, dbo.AREAS.AREA AS AREA_D, dbo.AREAS.SUBAREA AS SUBAREA_D, " & _
"dbo.AREAS.U_AREA AS U_AREA_D, dbo.DET_SALIDA.COD AS CODBIEN, dbo.BIEN.PARTIDA, dbo.BIEN.DESCRIPCION, dbo.BIEN.UNIDAD, " & _
"dbo.DET_SALIDA.CANTIDAD, dbo.DET_SALIDA.PRECIO, dbo.DET_SALIDA.CANTIDAD * dbo.DET_SALIDA.PRECIO AS SUBTOTAL, " & _
"dbo.DET_SALIDA.STOCK_ALDIA AS STOCK, dbo.CAB_SALIDA.FECHMOD, dbo.CAB_SALIDA.USERMOD, dbo.CAB_SALIDA.FECHA, " & _
"dbo.MODALIDAD.DESCRIPCION AS MODALIDAD " & _
"FROM CAB_SALIDA INNER JOIN " & _
"dbo.DET_SALIDA ON dbo.CAB_SALIDA.IDSALIDA = dbo.DET_SALIDA.IDSALIDA INNER JOIN " & _
"dbo.DOCUMENTO ON dbo.CAB_SALIDA.IDSALIDA = dbo.DOCUMENTO.IDSALIDA INNER JOIN " & _
"dbo.AREAS ON dbo.CAB_SALIDA.CODAREAD = dbo.AREAS.CODAREA INNER JOIN " & _
"dbo.AREAS AREAS_1 ON dbo.CAB_SALIDA.CODAREAO = AREAS_1.CODAREA INNER JOIN " & _
"dbo.BIEN ON dbo.DET_SALIDA.COD = dbo.BIEN.COD INNER JOIN " & _
"dbo.MODALIDAD ON dbo.CAB_SALIDA.MODALIDAD = dbo.MODALIDAD.CodTab where Numero = '" & TxtEBusca.Text & "'"
AsignaRst RstPec, sql, DbPrin
If RstPec.RecordCount > 0 Then Set Me.DgEdicion.DataSource = RstPec
End Sub
..........
PD.: A veces creo q estoy mal desde las vistas de mi base de datos pero al menos quisiera una idea de como seguir...gracias
capricorniana1977@hotmail.com-----> Karmen