ms access - Error: cannot update, database or object read only while edit record set in another function -


i'm passing record set 1 function (i.e.chkmismatchdata) (checkmismatches) , if record not found update values of passed recordset.

even declare variable of recordset in module level still finding error.

my code :

set rec1 = currentdb.openrecordset("select * cbwcfavendormatchoffmaster [vendor]='" & rec![vendor] & "'") while not rec.eof              set rec3 = currentdb.openrecordset("select id,[hci_no],clearloc,sum([amount])as amount1 cbwcfamisupload [vendor]='" & rec![vendor] & "' , nz([match],'')='' , nz([hci_no],'')<>'' group hci_no,clearloc,id ")     while not rec3.eof          set rec2 = currentdb.openrecordset("select id,depslipno,clearloc cbwcfapendingpaymentdata [depslipno]='" & rec3![hci_no] & "' group depslipno,clearloc,id having clearloc='" & rec3![clearloc] & "' , sum([amt])=" & rec3![amount1])         if rec2.eof = false              if rec2.recordcount = 1                 currentdb.execute ("update cbwcfamisupload set [match]='y' ,[cashin_id]='" & rec2![id] & "' [hci_no]='" & rec3![hci_no] & "'  ")                 currentdb.execute ("update cbwcfapendingpaymentdata set [match]='y' ,[mis_id]='" & rec3![id] & "' [depslipno]='" & rec3![hci_no] & "'")             elseif rec1.recordcount > 1                 call updaterec(rec3, 0, "duplicate match", 0)             end if          else             strsliptype = "hci_no"             call updaterec(rec3, 0, checkmismatches(rec3), 0) 'here im passing          end if          rec3.movenext     wend  wend   private function checkmismatches(rec dao.recordset) string dim reccheck dao.recordset dim strdepslipno string, strid string     if strsliptype = "hci_no"         '--clearing loc not matching         set reccheck = currentdb.openrecordset("select id,depslipno,clearloc cbwcfapendingpaymentdata [depslipno]='" & rec![hci_no] & "' group depslipno,clearloc,id having clearloc<>'" & rec![clearloc] & "' ,  sum([amt])=" & rec![amount1])         if reccheck.eof = true             rec.edit 'here i'm geting error             rec![match]="y"    'added line             rec!.update 'added line             checkmismatches = "clearing loc not matching"             reccheck.close             exit function         end if         reccheck.close end function 

your rec3 has group by clause.

a recordset aggregated definition read-only. have edit table separately recordset.

why have rec.edit in function when don't edit fields of it?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -