🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych.msaccess
Article #133971

err 91 co jest skopane

#133971
From: Marek Olkowski
Date: Tue, 03 Apr 2018 13:26
99 lines
2603 bytes
Witam
czy ktoś może mnie nakierować.
przy 6 edycji wywala 91 albo 3003
funkcja umieszczona w module
wywoływana w formularzu jak poniżej

If mRecordset.LanEditFrm(Me, "KartotekaTowaru", "Pr_Id", Me.lstKartoteka.Column(0), DB_LONG) = True Then end if

........... moduł..........

Public Function LanEditFrm(frm As Form, domain, keyName As String, whereValue As String, KeyNameType As String, _
                                Optional keyName2 As String, Optional whereValue2 As String, Optional KeyName2Type As String, _
                                            Optional OrderBy As String) As Boolean


Dim rs As Recordset
Dim db As Database
Dim ctl As Control
Dim vartemp As Variant
Dim strSQL As String

 
      strSQL = mSQLString.SQLString(domain, keyName, whereValue, KeyNameType, _
                                 keyName2, whereValue2, KeyName2Type, _
                                            OrderBy)
                              
 'sprawdzi czy istnieją rekordy
    
   On Error GoTo ErrorHandler
  
     'Otwarcie połączenia utworzenie rs
     Set db = CurrentDb()
     Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
     
    
    If rs.RecordCount = 0 Then
 ' jeśli brak rekordów
     MsgBox "Brak danych !!", vbInformation, "komunikat "
                   
 
 Else
 
     'Edytowanie rekordu
         rs.Edit
             'Iteracja poprzez poszczególne pola formularza, których nazwy 
              'odpowiadają
             ' nazwom elementów obiektu Recordset
         
         For Each ctl In frm.Controls
            'pola nie ma w formularzu - błąd
            
            On Error Resume Next
            Err = 0
            ctl.Value = rs.Fields(ctl.Name)
            
            If Err = 0 Then
                On Error GoTo ErrorHandler
                
                    End If
                       
        Next
        
        
       End If
       
       ' posprzataj
        rs.Close
        db.Close
             'Set rs = Nothing
                 'Set db = Nothing
      LanEditFrm = True
 GoTo Done

ErrorHandler:
If Err = 3003 Then ' zbyt wiele zagnieżdzonych tranzakcji
rs.Close
db.Close
            Set rs = Nothing
            Set db = Nothing
              End If
              
  MsgBox "Error :" & "  mRecordset.EditFrm" & " " & domain & " " & _
  Err.Number & vbCrLf & vbCrLf & Err.Description, vbInformation, LoadString(BazaNazwa)


Done:

End Function


Pozdrawiam 

Marek

Message-ID: <7fc20a41-c9e9-4ad3-ace9-71ae021c5d98@googlegroups.com>
Path: polish.pugleaf.net!archive.newsdeef.eu!archive!apf9.newsdeef.eu!not-for-mail