Run-time error 3136

Run-time error 3136

Post by Egil J?rgense » Tue, 08 Sep 1998 04:00:00



Hi all

I hope there is someone who can help me with this..couse I'm stuck in
this.
Thank's so much in advance

The problem is to updating a field in a database (Table name:
Medlemsliste, Field name: B?tplass).
Everything goes fine to the first 135 records, after that I get this
run-time error
it says:
Run-time error 3136
Couldn't insert or paste;data too long for field.

The field (B?tplass) in the database is Text and 4 characters,none of
the records in this field
is over 4 characters (some are blank).

Here is the code:

Private Sub Command2_Click()

Dim temp1 As String
Dim AntallRecords As Long
Set MyWs = DBEngine.Workspaces(0)
Set MyDb = MyWs.OpenDatabase(ProgPath & DBName)
Set MySet = MyDb.OpenRecordset("Medlemsliste", dbOpenTable)
AntallRecords = MySet.RecordCount
Label10.Caption = "Antall dataposter ? oppdatere : " & AntallRecords

    Do Until MySet.EOF
        temp1 = FormaterBatplassnr(MySet![B?tplass])         'Call to
function
        MySet.Edit
        MySet![B?tplass] = temp1
        MySet.Update
        MySet.MoveNext
        Label10.Caption = AntallRecords - 1
    Loop

MySet.Close
MyDb.Close
MyWs.Close
End Sub

---------------------------------------------------------
'Function in module Bas file

Function FormaterBatplassnr(temp) As String
If temp < 10 Then
temp = "000" & temp
ElseIf temp >= 10 And temp < 100 Then
temp = "00" & temp
ElseIf temp >= 100 And temp < 999 Then
temp = "0" & temp
ElseIf temp >= 1000 And temp < 10000 Then
temp = temp
Else: temp = ""        'Blank records
End If
FormaterBatplassnr = temp            'return formatted with 4 characters
exept for blanks records
End Function
------------------------------------------------

Tank you so much again

Best Regards
Egil