Error 3021: No current record

ForcedToUseIt

Registered User.
Local time
Today, 18:35
Joined
Jul 25, 2004
Messages
34
Hi I have a .mdb FE running on a SQL server BE. When I run the following code I get the 3021 error: No current record in the line:
rst.FindFirst ("DrawNo = '" & DrawNo & "'")

Does anyone have advice for me. Do I have to convert the code to ADO to be able to do this or is there some workaround for this. BTW the recordset is usually empty so the error is not so surprizing but that is the way that I want it to be because im trying to fill the empty recordset as you can see.

Code:
Private Sub butStoreDrawings_Click()
  Dim dbs As DAO.Database
  Dim rst As DAO.Recordset
  Dim strSQL As String
  Dim TransNo As Long
  Dim DrawNo As String
  Dim continue As Boolean
  Dim currPos As String
  
  
  If IsNull(Me.combTransmittal.Value) Then
    continue = False
    MsgBox ("Please select transmittal ")
  Else
    continue = True
    TransNo = Me.combTransmittal.Value
  End If
  
  If continue Then
    Set dbs = CurrentDb()
    strSQL = "SELECT * FROM tblTransDrawingList WHERE TransNo = " & TransNo
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
    
    Me.Painting = False
    currPos = Me.Bookmark
    Me.Recordset.MoveFirst
    While Not (Me.Recordset.EOF)
      If Me.Transm.Value Then
        DrawNo = Me.DrawNo
        rst.FindFirst ("DrawNo = '" & DrawNo & "'")
        If rst.NoMatch Then
          rst.AddNew
          rst.Fields("TransNo") = TransNo
          rst.Fields("DrawNo") = DrawNo
          rst.Fields("DrawName") = Left(Me.DrawName, 148)
          rst.Fields("Rev") = Me.Rev
          rst.Fields("RevDate") = Me.Revisions_Date
          rst.Update
        Else
          rst.Edit
          rst.Fields("DrawName") = Left(Me.DrawName, 148)
          rst.Fields("Rev") = Me.Rev
          rst.Fields("RevDate") = Me.Revisions_Date
          rst.Update
        End If
      End If
      Me.Recordset.MoveNext
    Wend
    Me.Bookmark = currPos
    Me.Painting = True
  End If
End Sub

Any help would be much appreceated.
 
I found the solution. The code is just getting uglier by the minute but it works so Im happy...
Anyway here is the solution:

Code:
Private Sub butStoreDrawings_Click()
  Dim dbs As DAO.Database
  Dim rst As DAO.Recordset
  Dim strSQL As String
  Dim TransNo As Long
  Dim DrawNo As String
  Dim continue As Boolean
  Dim currPos As String
  
  
  If IsNull(Me.combTransmittal.Value) Then
    continue = False
    MsgBox ("Please select transmittal ")
  Else
    continue = True
    TransNo = Me.combTransmittal.Value
  End If
  
  If continue Then
    Set dbs = CurrentDb()
    strSQL = "SELECT * FROM tblTransDrawingList WHERE TransNo = " & TransNo
    Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
    
    Me.Painting = False
    currPos = Me.Bookmark
    Me.Recordset.MoveFirst
    While Not (Me.Recordset.EOF)
      If Me.Transm.Value Then
        DrawNo = Me.DrawNo [COLOR=Lime]
        If rst.RecordCount = 0 Then
          rst.AddNew
          rst.Fields("TransNo") = TransNo
          rst.Fields("DrawNo") = DrawNo
          rst.Fields("DrawName") = Left(Me.DrawName, 148)
          rst.Fields("Rev") = Me.Rev
          rst.Fields("RevDate") = Me.Revisions_Date
          rst.Update
        Else [/COLOR]          
          rst.FindFirst ("DrawNo = '" & DrawNo & "'")
          If rst.NoMatch Then
            rst.AddNew
            rst.Fields("TransNo") = TransNo
            rst.Fields("DrawNo") = DrawNo
            rst.Fields("DrawName") = Left(Me.DrawName, 148)
            rst.Fields("Rev") = Me.Rev
            rst.Fields("RevDate") = Me.Revisions_Date
            rst.Update
          Else
            rst.Edit
            rst.Fields("DrawName") = Left(Me.DrawName, 148)
            rst.Fields("Rev") = Me.Rev
            rst.Fields("RevDate") = Me.Revisions_Date
            rst.Update
          End If [COLOR=Lime]
        End If [/COLOR]
      End If
      Me.Recordset.MoveNext
    Wend
    Me.Bookmark = currPos
    Me.Painting = True
  End If
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom