Toon posts:

Visual Basic update error, pls help me

Pagina: 1
Acties:
  • 45 views sinds 30-01-2008

Verwijderd

Topicstarter
ik probeer uit louter code de access records te manipuleren. Alles werkt perfect, behalve records toevoegen geeft problemen.

de code is:
Option Explicit
Dim cnnADO As New ADODB.Connection
Dim comTADO As New ADODB.Command
Dim rsTADO As New ADODB.Recordset

Private Sub cmdEmail_Click()
Set outl = New InternetExplorer
outl.Visible = False
outl.Navigate "mailto:" & txtEmail
End Sub

Private Sub Form_Load()

cnnADO.Provider = "Microsoft.Jet.OLEDB.4.0"
cnnADO.ConnectionString = "telefoonlijst.MDB"
cnnADO.Open

comTADO.ActiveConnection = cnnADO
comTADO.CommandText = "SELECT * FROM telefoonlijst"
rsTADO.CursorLocation = adUseClient
rsTADO.CursorType = adOpenDynamic
rsTADO.LockType = adLockPessimistic
rsTADO.Open comTADO

Set MSHFlexGrid1.Recordset = rsTADO
ReadRecord

End Sub

Private Sub cmdNavigeer_Click(Index As Integer)

Dim SQLString As String
Dim SQLkey As String

With rsTADO
Select Case Index

Case 0 ' movefirst
.MoveFirst
Case 1 ' moveprevious
.MovePrevious
If .BOF Then .MoveFirst
Case 2 'movenext
.MoveNext
If .EOF Then .MoveLast
Case 3 ' movelast
.MoveLast
Case 4 'nieuw
.AddNew
Case 5 'bewaren
.Update
.MoveLast
PasFlexGridAan
MsgBox "nieuw records toegevoegd"

Case 6 'wissen
.Delete
.MoveNext
PasFlexGridAan
If .EOF Then
.MoveLast
End If
End Select
End With

ReadRecord

End Sub

Public Sub ReadRecord()

txtID = GetValue(rsTADO!RecordNummer)
txtVoornaam = GetValue(rsTADO!voornaam)
txtTV = GetValue(rsTADO!Tussenvoegsel)
txtNaam = GetValue(rsTADO![achternaam])
txtStraatnaam = GetValue(rsTADO!straatnaam)
txtHuisnummer = GetValue(rsTADO!Huisnummer)
txtPostcode = GetValue(rsTADO!Postcode)
txtWoonplaats = GetValue(rsTADO!woonplaats)
txtTelefoonnummer = GetValue(rsTADO!Telefoonnummer)
txtMobiel = GetValue(rsTADO![GSM-Nummer])
txtEmail = GetValue(rsTADO![E-mail adres])



End Sub

Private Function GetValue(TabelVeld As Field) As String
GetValue = IIf(IsNull(TabelVeld), Empty, TabelVeld)
End Function


Private Sub PasFlexGridAan()

Dim SQLcode As String, SQLkey As String
SQLkey = Val(Trim(txtID.Text))
SQLcode = "select * from telefoonlijst"
comTADO.CommandText = SQLcode
rsTADO.Requery
Set MSHFlexGrid1.Recordset = rsTADO

End Sub


Private Sub MSHFlexGrid1_Click()

rsTADO.Filter = ""
With MSHFlexGrid1
If .Col <> 1 Then .Col = 1
rsTADO.MoveFirst
rsTADO.Find ("recordnummer = " & Val(MSHFlexGrid1.Text))

ReadRecord

End With

End Sub

  • Janoz
  • Registratie: Oktober 2000
  • Laatst online: 09-09 20:58

Janoz

Moderator Devschuur®

!litemod

Dit topic voldoet eigenlijk bij langena niet aan de eisen gesteld in de quickstart..

je hele source posten met de mededeling "Hij doet het niet" zijn we hier niet echt van gediend.

Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'


Dit topic is gesloten.