Can't pull data from a VB6 text box to access database

hellboy83

New member
Local time
Yesterday, 18:07
Joined
Sep 12, 2008
Messages
4
Hi guys,

I'm currently working with VB6 and access but I'm facing difficulties when i try to pull data entered in a VB6 textbox to a database access of my own.

It reports me the following error:

Run-time error '3251':

Current Recordset does not support updating. This may be a limitation
of the provider, or of the selected locktype.


==============================================================

Here is my following code.
Can somebody help me please:

Option Explicit

Dim mobjADOConn As adodb.Connection

Dim Funcionario_Tbl As adodb.Recordset

Private mblnUpdatePending As Boolean

Dim mstrUpdateType As String

Private Sub DataLoad()

'copy the data from the recordset to the text boxes:
txtFuncioID.Text = Funcionario_Tbl.Fields("Funcio_ID")
txtF_Nome.Text = Funcionario_Tbl.Fields("F_Nome")
txtF_Area.Text = Funcionario_Tbl.Fields("F_Area")

End Sub

Private Sub OpenNewRecordset()

Set Funcionario_Tbl = New adodb.Recordset
Funcionario_Tbl.CursorLocation = adUseClient
Funcionario_Tbl.Open Funcionario, mobjADOConn, adOpenStatic, adCmdText

End Sub

Private Sub cmdadd_Click()

txtFuncioID.Text = ""
txtF_Nome.Text = ""
txtF_Area.Text = ""

SetFormState True
mstrUpdateType = "A"
txtFuncioID.SetFocus

End Sub

Private Sub cmdanterior_Click()
Funcionario_Tbl.MovePrevious
If Funcionario_Tbl.BOF Then
Beep
Funcionario_Tbl.MoveFirst
End If
Call DataLoad
Exit Sub
End Sub

Private Sub cmdprimeiro_Click()
Funcionario_Tbl.MoveFirst
Call DataLoad
Exit Sub
End Sub

Private Sub cmdproximo_Click()
Funcionario_Tbl.MoveNext
If Funcionario_Tbl.EOF Then
Beep
Funcionario_Tbl.MoveLast
End If
Call DataLoad
Exit Sub
End Sub

Private Sub cmdR_ultimo_Click()
Requisicoes_Tbl.MoveLast
Call DataLoad
Exit Sub
End Sub

Private Sub cmdsave_Click()

If mstrUpdateType = "A" Then

Funcionario_Tbl.AddNew
End If

Funcionario_Tbl.Fields("Funcio_ID") = txtFuncioID.Text
Funcionario_Tbl.Fields("F_Nome") = txtF_Nome.Text
Funcionario_Tbl.Fields("F_Area") = txtF_Area.Text
Funcionario_Tbl.Update

If mstrUpdateType = "A" Then
'after the new record is added, the db must be re-queried
'so that the resultset contains the new record:
Funcionario_Tbl.Requery
' reposition to the record just added
Funcionario_Tbl.Find "Funcio_ID = " & txtFuncioID.Text
'display status info about the new record
End If

Reset:
SetFormState False

Exit Sub

Resume Reset

End Sub

Private Sub cmdultim_Click()
Cliente_Tbl.MoveLast
Call DataLoad
Exit Sub
End Sub

Private Sub cmdultimo_Click()
Funcionario_Tbl.MoveLast
Call DataLoad
Exit Sub
End Sub

Private Sub cmdForNext_Click()

Fornecedor_Tbl.MoveNext
If Fornecedor_Tbl.EOF Then
Beep
Fornecedor_Tbl.MoveLast
End If
Call DataLoad
Exit Sub

End Sub

Private Sub cmdForPrevious_Click()
Fornecedor_Tbl.MovePrevious
If Fornecedor_Tbl.BOF Then
Beep
Fornecedor_Tbl.MoveFirst
End If
Call DataLoad
Exit Sub
End Sub

Private Sub cmdForlast_Click()
Fornecedor_Tbl.MoveLast
Call DataLoad
Exit Sub

End Sub

Private Sub cmdForfirst_Click()
Fornecedor_Tbl.MoveFirst
Call DataLoad
Exit Sub
End Sub

Private Sub Form_Load()
'set up the form and connect to the data source

'center the form:
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2

' Connect to the Property database:
Set mobjADOConn = New adodb.Connection
mobjADOConn.ConnectionString = "DSN=GESTAO;Uid=admin;Pwd=;"
mobjADOConn.Open

Call AllData

SetFormState False

Exit Sub

End Sub
Private Sub SetFormState(pblnEnabled As Boolean)

txtFuncioID.Enabled = pblnEnabled
txtF_Nome.Enabled = pblnEnabled
txtF_Area.Enabled = pblnEnabled

cmdsave.Enabled = pblnEnabled
cmdcancel.Enabled = pblnEnabled

cmdadd.Enabled = Not pblnEnabled
cmdedit.Enabled = Not pblnEnabled
cmddelete.Enabled = Not pblnEnabled
cmdupdate.Enabled = Not pblnEnabled

mblnUpdatePending = pblnEnabled

End Sub

Private Sub AllData()

'select or reload the data to be displayed:
Funcionario = "select * from Funcionario_Tbl"
Cliente = "select * from Cliente_Tbl"
Fornecedor = "select * from Fornecedor_Tbl"
Material = "select * from Material_Tbl"
Fornecimento = "select * from Fornecimento_Tbl"
Requisicoes = "select * from Requisicoes_Tbl"
Distribuicao = "select * from Distribuicao_Tbl"

Call OpenNewRecordset

Call DataLoad

Exit Sub

End Sub
 

Users who are viewing this thread

Back
Top Bottom