Acudo aqui de nuevo con un problemilla en un simple formulario que realiza altas, bajas, cambios en una tabla de una base de datos.
Tengo 5 textboxes que pertenecen a cada campo de mi tabla enlazados mediante un adodc
Codigo:
Código:
Y el código del boton que es para agregar los datos de los 5 text a la base de datos es:Private Sub Form_Load() Dim DBPath As String DBPath = App.Path If Right(DBPath, 1) <> "\" Then DBPath = DBPath & "\" DBPath = DBPath & "BDVC.mdb" Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & DBPath & "';" Adodc1.RecordSource = "select * from CLIENTE" Set Text1.DataSource = Adodc1 Set Text2.DataSource = Adodc1 Set Text3.DataSource = Adodc1 Set Text4.DataSource = Adodc1 Set Text5.DataSource = Adodc1 Text1.DataField = "id_cte" Text2.DataField = "nom_cte" Text3.DataField = "ap_cte" Text4.DataField = "dir_cte" Text5.DataField = "tel_cte" Adodc1.Refresh End Sub
Código:
El conflicto esta en que los campos estan enlazados, pero no puedo desenlazarlos porque asi los necesito para el resto de las operaciones Private Sub Agrega_Click()
If Val(Text1.Text) = 0 Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Then
MsgBox "Error - Debe llenar todos los datos.", vbCritical
Else
On Error Resume Next
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("id_cte").Value = Text1.Text
Adodc1.Recordset.Fields("nom_cte").Value = Text2.Text
Adodc1.Recordset.Fields("ap_cte").Value = Text3.Text
Adodc1.Recordset.Fields("dir_cte").Value = Text4.Text
Adodc1.Recordset.Fields("tel_cte").Value = Text5.Text
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.Recordset.MoveLast
If Err.Number Then
Err.Clear
MsgBox "Error al ingresar los datos.", vbCritical
Else
MsgBox "Registro Agregado.", vbInformation
'Text1.SetFocus
End If
End If
End Sub
.Entonces si pueden ayudarme ps de antemano GRACIAS

