Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Oct 2002
    Location
    Houston, Texas, USA
    Posts
    303
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB Error code (VBA Script)

    I am getting DAO.RecrodSet: Update or Cancel update without Addnew or Edit" Line 55(RST.UPDATE) Not sure what I am doing wrong.

    '-=-=-=-=-=-=-=-=-=-=-=-=-
    'Start Manager Approval
    '-=-=-=-=-=-=-=-=-=-=-=-=-
    Sub status33()
    Dim Dbe
    Dim MyDB
    Dim Rst
    Dim Rsm

    'On error resume next
    Set Dbe=Application.CreateObject("DAO.DBEngine.36")
    If Err.Number <> 0 Then
    MsgBox Err.Description &"--Some functions may not work correctly"_
    & Chr(13) & "Please make sure that DAO 3.6 is installed on this machine"
    Exit Sub
    End If

    set nms=application.getnamespace("mapi")
    vrUser=nms.currentuser
    UserProperties.Find("Reqby").Value = vrUser
    UserProperties.Find("txtstatus").Value="Dept. Manager"
    End Sub
    '-=-=-=-=-=-=-=

    '-=-=-=-=-=-=-=-=-=-=-=-
    Sub Update44()
    Dim Dbe
    Dim MyDB
    Dim Rst
    Dim Rsm

    'On error resume next
    Set Dbe = Application.CreateObject("DAO.DBEngine.36")
    If Err.Number <> 0 Then
    MsgBox Err.Description & "--- Some functions may not work correctly" _
    & Chr(13) & "Please make sure that DAO 3.6 is installed on this machine"
    Exit sub
    End If

    Set MyDB = Dbe.Workspaces(0).OpenDatabase("tabsnasdatabase$ed garnewcigarsnewcigars3.mdb")
    RequestNum = UserProperties.Find("jobnum").Value
    Set Rst = MyDB.OpenRecordset("select * from dbtask where tasknum = " & RequestNum)

    If Rst.EOF = True And Rst.BOF = True Then '
    MsgBox "Empty record or not found" 'error hand
    Else
    Rst.Edit
    Rst.Fields(2).Value = UserProperties.Find("Reqby").Value
    Rst.Fields(4).Value = UserProperties.Find("txtstatus").Value
    End if
    Rst.Update <---------------------------------------------------------------------------------------------- Getting Error at this point.........................
    Rst.Close
    MyDB.Close
    End Sub
    '-=-=-=-=-=-=-=-=-=-=-=-

    '=-=-=-=-=-=-=
    Sub Update66()
    Dim DObe
    Dim MyDB
    Dim Rst
    Dim Rsm

    'On error resume next
    Set Dbe = Application.CreateObject("DAO.DBEngine.36")
    If Err.Number <> 0 Then
    MsgBox Err.Description & "--- Some functions may not work correctly" _
    & Chr(13) & "Please make sure that DAO 3.6 is installed on this machine"
    Exit sub
    End If

    Set MyDB = Dbe.Workspaces(0).OpenDatabase("tabsnasdatabase$ed garnewcigarsnewcigars3.mdb")
    RequestNum = UserProperties.Find("jobnum").Value
    Set Rst = MyDB.OpenRecordset("select * from dbUserID where jobnum = " & RequestNum)

    If Rst.EOF = True And Rst.BOF = True Then
    Set Rst = MyDB.OpenRecordset("dbUserID")
    rst.addnew
    Else
    rst.edit
    End if

    ' Access side Outlook side
    Rst.fields("approval1") = UserProperties.Find("approval1").Value
    Rst.fields("disapproval1") = UserProperties.Find("disapproval1").Value
    Rst.fields("dept1") = UserProperties.Find("dept1").Value
    Rst.fields("request1") = UserProperties.Find("request1").Value
    Rst.update
    Rst.close
    MyDB.Close
    End Sub
    '-=-=-=-=-=-=-=-=-=-

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VB Error code (VBA Script)

    Does the error occur in those cases when you get the MsgBox? If so, try putting Rst.Update before the End If. If it occurs in all cases, I'm not sure.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •