Ayuda!! VB-ACCESS
Publicado por Paty Luna (2 intervenciones) el 01/11/2005 22:42:04
Hola, estoy haciendo un programa con vb y access y no puedo hacer k los botones
de "primer, anterior, siguiente, último" funcionen. Me dice k no se puede actualizar la base y k no se pueden llenar las filas hacia atrás... Soy novata en VB y la verdad no se como hacerle, aqui les va mi código haber si alguien me puede ayudar.
1,000,000 de Gracias.!!!!!
MARCA ERRORES EN EL RECORDSET (MOVE)
Attribute VB_Name = "ptkmod"
Option Explicit
Global db_file As String
Global conn As New ADODB.Connection
Global rs As ADODB.Recordset
Global id As String
Global statement As String
Public Function open_ptkconn()
' Open the database.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & _
"\"
db_file = db_file & "PTK.mdb"
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
End Function
Public Sub open_rscli()
Call open_ptkconn
statement = "SELECT * FROM Clientes"
Set rs = conn.Execute(statement)
End Sub
**********************
Private Sub Form_Load()
Dim i As Long
Call open_ptkconn
Call open_rscli
For i = 0 To 4
Set txt(i).DataSource = rs
Next
txt(0).DataField = "nombre"
txt(1).DataField = "direccion"
txt(2).DataField = "tel"
txt(3).DataField = "Empresa"
txt(4).DataField = "num_tran"
cmdUpdate.Enabled = False
End Sub
Private Sub cmdAdd_Click()
Call open_ptkconn
Call open_rscli
With rs
.AddNew
.Update
End With
End Sub
Private Sub cmdClose_Click()
Load frmMenu
frmMenu.Show
Unload Me
End Sub
Private Sub cmdDelete_Click()
Call open_ptkconn
Call open_rscli
MsgBox ("Está seguro de que desea borrar este registro?")
If confirm = vbYes Then
rs.Delete
MsgBox "Registro Eliminado!"
Else
MsgBox "Registo no Eliminado!"
End If
End Sub
Private Sub cmdF_Click()
Call open_ptkconn
Call open_rscli
rs.MoveFirst
End Sub
Private Sub cmdL_Click()
Call open_ptkconn
Call open_rscli
rs.MoveLast
End Sub
Private Sub cmdP_Click()
Call open_ptkconn
Call open_rscli
If Not BOF Then
rs.MovePrevious
Else
MsgBox "Este es el primer registro"
End If
End Sub
Private Sub cmN_Click()
Call open_ptkconn
Call open_rscli
rs.MoveNext
End Sub
**********************
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmCliente
Caption = "Cliente"
ClientHeight = 5895
ClientLeft = 45
ClientTop = 435
ClientWidth = 9885
LinkTopic = "Form1"
ScaleHeight = 5895
ScaleWidth = 9885
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txttra
DataField = "num_tran"
DataSource = "Adodc1"
Height = 495
Left = 7080
TabIndex = 10
Top = 360
Width = 735
End
Begin MSAdodcLib.Adodc Adodc1
Height = 372
Left = 1080
Top = 2760
Width = 4092
_ExtentX = 7223
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PTK\PTK.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PTK\PTK.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "clientes"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton cmdCont
Caption = "&Ir a Contrato"
Height = 492
Left = 6480
TabIndex = 9
Top = 4440
Width = 1572
End
Begin VB.CommandButton cmdCancelar
Caption = "&Cancelar"
Height = 492
Left = 8400
TabIndex = 8
Top = 4440
Width = 972
End
Begin VB.TextBox txtEmp
DataField = "empresa"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 7
Top = 2160
Width = 3252
End
Begin VB.TextBox txtDir
DataField = "direccion"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 6
Top = 1560
Width = 3252
End
Begin VB.TextBox txtTel
DataField = "tel"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 5
Top = 960
Width = 3252
End
Begin VB.TextBox txtNom
DataField = "nombre"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 4
Top = 360
Width = 3252
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "Empresa:"
Height = 192
Left = 1080
TabIndex = 3
Top = 2160
Width = 696
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "Dirección:"
Height = 192
Left = 1080
TabIndex = 2
Top = 1560
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Teléfono:"
Height = 192
Left = 1080
TabIndex = 1
Top = 960
Width = 684
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Nombre:"
Height = 192
Left = 1080
TabIndex = 0
Top = 360
Width = 624
End
End
Attribute VB_Name = "frmCliente"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancelar_Click()
Unload Me
frmMenú.Show
End Sub
Private Sub cmdCont_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub Form_Load()
frmCliente.Cls
End Sub
***************
de "primer, anterior, siguiente, último" funcionen. Me dice k no se puede actualizar la base y k no se pueden llenar las filas hacia atrás... Soy novata en VB y la verdad no se como hacerle, aqui les va mi código haber si alguien me puede ayudar.
1,000,000 de Gracias.!!!!!
MARCA ERRORES EN EL RECORDSET (MOVE)
Attribute VB_Name = "ptkmod"
Option Explicit
Global db_file As String
Global conn As New ADODB.Connection
Global rs As ADODB.Recordset
Global id As String
Global statement As String
Public Function open_ptkconn()
' Open the database.
db_file = App.Path
If Right$(db_file, 1) <> "\" Then db_file = db_file & _
"\"
db_file = db_file & "PTK.mdb"
' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & db_file & ";" & _
"Persist Security Info=False"
conn.Open
End Function
Public Sub open_rscli()
Call open_ptkconn
statement = "SELECT * FROM Clientes"
Set rs = conn.Execute(statement)
End Sub
**********************
Private Sub Form_Load()
Dim i As Long
Call open_ptkconn
Call open_rscli
For i = 0 To 4
Set txt(i).DataSource = rs
Next
txt(0).DataField = "nombre"
txt(1).DataField = "direccion"
txt(2).DataField = "tel"
txt(3).DataField = "Empresa"
txt(4).DataField = "num_tran"
cmdUpdate.Enabled = False
End Sub
Private Sub cmdAdd_Click()
Call open_ptkconn
Call open_rscli
With rs
.AddNew
.Update
End With
End Sub
Private Sub cmdClose_Click()
Load frmMenu
frmMenu.Show
Unload Me
End Sub
Private Sub cmdDelete_Click()
Call open_ptkconn
Call open_rscli
MsgBox ("Está seguro de que desea borrar este registro?")
If confirm = vbYes Then
rs.Delete
MsgBox "Registro Eliminado!"
Else
MsgBox "Registo no Eliminado!"
End If
End Sub
Private Sub cmdF_Click()
Call open_ptkconn
Call open_rscli
rs.MoveFirst
End Sub
Private Sub cmdL_Click()
Call open_ptkconn
Call open_rscli
rs.MoveLast
End Sub
Private Sub cmdP_Click()
Call open_ptkconn
Call open_rscli
If Not BOF Then
rs.MovePrevious
Else
MsgBox "Este es el primer registro"
End If
End Sub
Private Sub cmN_Click()
Call open_ptkconn
Call open_rscli
rs.MoveNext
End Sub
**********************
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmCliente
Caption = "Cliente"
ClientHeight = 5895
ClientLeft = 45
ClientTop = 435
ClientWidth = 9885
LinkTopic = "Form1"
ScaleHeight = 5895
ScaleWidth = 9885
StartUpPosition = 3 'Windows Default
Begin VB.TextBox txttra
DataField = "num_tran"
DataSource = "Adodc1"
Height = 495
Left = 7080
TabIndex = 10
Top = 360
Width = 735
End
Begin MSAdodcLib.Adodc Adodc1
Height = 372
Left = 1080
Top = 2760
Width = 4092
_ExtentX = 7223
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PTK\PTK.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PTK\PTK.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "clientes"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton cmdCont
Caption = "&Ir a Contrato"
Height = 492
Left = 6480
TabIndex = 9
Top = 4440
Width = 1572
End
Begin VB.CommandButton cmdCancelar
Caption = "&Cancelar"
Height = 492
Left = 8400
TabIndex = 8
Top = 4440
Width = 972
End
Begin VB.TextBox txtEmp
DataField = "empresa"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 7
Top = 2160
Width = 3252
End
Begin VB.TextBox txtDir
DataField = "direccion"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 6
Top = 1560
Width = 3252
End
Begin VB.TextBox txtTel
DataField = "tel"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 5
Top = 960
Width = 3252
End
Begin VB.TextBox txtNom
DataField = "nombre"
DataSource = "Adodc1"
Height = 372
Left = 2400
TabIndex = 4
Top = 360
Width = 3252
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "Empresa:"
Height = 192
Left = 1080
TabIndex = 3
Top = 2160
Width = 696
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "Dirección:"
Height = 192
Left = 1080
TabIndex = 2
Top = 1560
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Teléfono:"
Height = 192
Left = 1080
TabIndex = 1
Top = 960
Width = 684
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Nombre:"
Height = 192
Left = 1080
TabIndex = 0
Top = 360
Width = 624
End
End
Attribute VB_Name = "frmCliente"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCancelar_Click()
Unload Me
frmMenú.Show
End Sub
Private Sub cmdCont_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub Form_Load()
frmCliente.Cls
End Sub
***************
Valora esta pregunta


0