Access - PARA XAVI

 
Vista:

PARA XAVI

Publicado por ROBERTO (145 intervenciones) el 18/10/2007 18:21:56
Otra cosilla. Si ahora yo lo que quiero es modificar un registro no añadirlo no solo es utilizando .edit en lugar de .addnew no? Estoy intentandolo y no hace lo que quiero a veces me modifica o me añade. Una locura.

Mira e puesto otro boton distinto para modificar un registro ya insertado que hace lo siguiente.

Private Sub Etiqueta140_Click()
Dim rst As DAO.Recordset
Dim pst As DAO.Recordset
Dim dst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("select * From [PREPARACION PEDIDO (REFERENCIAS)] where [ENTPRE]= " & Me!ENTPRE)
Set pst = CurrentDb.OpenRecordset("PEDIDOS_ENTRADAS")
Set dst = CurrentDb.OpenRecordset("select * From [PREPARACION PEDIDO(FECHA)] where [ID]= " & Me!ENTPRE)

rst.MoveLast
If rst.RecordCount = 0 Then
MsgBox ("No hay registros que modificar"), vbCritical
Exit Sub
End If

rst.MoveFirst
While Not rst.EOF
pst.Edit
pst![Nº ENTRADA] = rst![IDREF]
pst!ENTRADA = rst![CANT]
pst![IMPORTE DOLAR] = rst![FOBNUEVO]
pst!AR = rst![ARANCEL]

pst![FECHA] = dst![FECHA ENTRADA]
pst![GASTOS] = dst![GASTOS%]
pst![IVA] = dst![R%]
pst![CAMBIO] = dst![CAMBIO]
pst.Update
rst.MoveNext

Wend
rst.Close
pst.Close
dst.Close
Set rst = Nothing
Set pst = Nothing
Set dst = Nothing

MsgBox ("Registros modificados"), vbInformation
End Sub


Si se pudiese hacer todo de un tirón , quiero decir insertar registros y cuando sea necesario poder modificarlos seria perfecto. venga gracias y a ver si me puedes ayudar con esto. Gracias.
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