Solved

cannot edit dao.recordset

Posted on 2014-09-03
3
156 Views
Last Modified: 2014-09-03
I have added a small section onto a previous function but when it tries to edit it gives error 3027, cannot update.

Not sure why.

Private Function BtnPrepareData_Click(Clien<wbr ></wbr>tName As String, ManfName As String, ModelName As String)
Dim QryName As String
Dim countrecords As Long

Dim sqltext As String
Dim sqlAlternate As String
Dim StrTable As String
Dim Db As DAO.Database
Set Db = CurrentDb()
Dim qdfNew As DAO.QueryDef
Dim RstCUREmpty As DAO.Recordset
StrTable = "ClientWordGroups"
QryName = "Qryupdateunwantedfield"

DoCmd.SetWarnings False
DoCmd.OpenQuery "QryReplaceQuotes"

Dim SqltoUse As Boolean

SqltoUse = InAutoRangeList(ModelName)<wbr ></wbr>
If SqltoUse = False Then

sqltext = "UPDATE ClientWordGroups SET ClientWordGroups.Concatena<wbr ></wbr>tedUnwante<wbr ></wbr>dRemoval =" _
& " replacemulti([concatenated<wbr ></wbr>],'" & ClientName & "','" & ManfName & "')" _
& " WHERE (((ClientWordGroups.Client<wbr ></wbr>)='" & ClientName & "') AND ((ClientWordGroups.MarqueA<wbr ></wbr>lias)='" & ManfName & "') AND ((ClientWordGroups.concate<wbr ></wbr>nated) Like '*" & ModelName & "*'));" _




Else

sqltext = "UPDATE ClientWordGroups SET ClientWordGroups.Concatena<wbr ></wbr>tedUnwante<wbr ></wbr>dRemoval =" _
& " replacemulti([concatenated<wbr ></wbr>],'" & ClientName & "','" & ManfName & "')" _
& " WHERE (((ClientWordGroups.Client<wbr ></wbr>)='" & ClientName & "') AND ((ClientWordGroups.MarqueA<wbr ></wbr>lias)='" & ManfName & "') AND ((ClientWordGroups.groups)<wbr ></wbr> Like '*" & ModelName & "*'));" _





End If

Debug.Print sqltext


If IsTableQuery("", QryName) = True Then

    DoCmd.DeleteObject acQuery, QryName
End If


Set qdfNew = CurrentDb.CreateQueryDef(Q<wbr ></wbr>ryName, sqltext)
qdfNew.SQL = sqltext


DoCmd.OpenQuery QryName

DoCmd.DeleteObject acQuery, QryName

'*************************<wbr ></wbr>**********<wbr ></wbr>**
' maybe routine needed here to check for concatenatedunwantedremova<wbr ></wbr>l wordcount and where no words add no trim level.

' all works fine till here where it fails on edit
sqltext = "SELECT ClientWordGroups.concatena<wbr ></wbr>ted, ClientWordGroups.Manufactu<wbr ></wbr>rerName, ClientWordGroups.Client, ClientWordGroups.Concatena<wbr ></wbr>tedUnwante<wbr ></wbr>dRemoval,"<wbr ></wbr> _
& " ClientWordGroups.MarqueAli<wbr ></wbr>as, ClientWordGroups.OriginalS<wbr ></wbr>tring, ClientWordGroups.Groups, ClientWordGroups.Concatena<wbr ></wbr>tedUnwante<wbr ></wbr>dRemovalCo<wbr ></wbr>py, QryWork.ClientName, QryWork.Marque," _
& " IIf(IsNull([concatenatedun<wbr ></wbr>wantedremo<wbr ></wbr>val])=True<wbr ></wbr>,True,isba<wbr ></wbr>semodel([c<wbr ></wbr>oncatenate<wbr ></wbr>dunwantedr<wbr ></wbr>emoval])) AS Expr1" _
& " FROM ClientWordGroups LEFT JOIN QryWork ON (ClientWordGroups.Client = QryWork.ClientName) AND (ClientWordGroups.MarqueAl<wbr ></wbr>ias = QryWork.Marque)" _
& " WHERE (((QryWork.ClientName) Is Not Null) AND ((QryWork.Marque) Is Not Null) AND ((IIf(IsNull([concatenated<wbr ></wbr>unwantedre<wbr ></wbr>moval])=Tr<wbr ></wbr>ue,True,is<wbr ></wbr>basemodel(<wbr ></wbr>[concatena<wbr ></wbr>tedunwante<wbr ></wbr>dremoval])<wbr ></wbr>))=True));<wbr ></wbr>"

Debug.Print sqltext

Set RstCUREmpty = Db.OpenRecordset(sqltext)
'
With RstCUREmpty
      .MoveLast
    countrecords = .RecordCount
 .MoveFirst
    'cycle through the recordset
    Do Until RstCUREmpty.EOF

'*************************<wbr ></wbr>****** error here

        .Edit
        
        .Fields("concatenatedunwan<wbr ></wbr>tedremoval<wbr ></wbr>").Value = "[no trim preclean new]"
        
        .Update
     .movenext   
    Loop

End With


RstCUREmpty.Close
Set RstCUREmpty = Nothing
Set Db = Nothing



DoCmd.SetWarnings True
End Function

Open in new window


i am in access vba

The recordset does have rows.

the actual sql is here:
SELECT ClientWordGroups.concatenated, ClientWordGroups.ManufacturerName, ClientWordGroups.Client, ClientWordGroups.ConcatenatedUnwantedRemoval, ClientWordGroups.MarqueAlias, ClientWordGroups.OriginalString, ClientWordGroups.Groups, ClientWordGroups.ConcatenatedUnwantedRemovalCopy, QryWork.ClientName, QryWork.Marque, IIf(IsNull([concatenatedunwantedremoval])=True,True,isbasemodel([concatenatedunwantedremoval])) AS Expr1
FROM ClientWordGroups LEFT JOIN QryWork ON (ClientWordGroups.MarqueAlias = QryWork.Marque) AND (ClientWordGroups.Client = QryWork.ClientName)
WHERE (((QryWork.ClientName) Is Not Null) AND ((QryWork.Marque) Is Not Null) AND ((IIf(IsNull([concatenatedunwantedremoval])=True,True,isbasemodel([concatenatedunwantedremoval])))=True));

Open in new window

0
Comment
Question by:PeterBaileyUk
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 40300620
Try to run the strSQL manually. If it won't update, neither will your code.

/gustav
0
 

Author Comment

by:PeterBaileyUk
ID: 40300648
I've requested that this question be deleted for the following reason:

couldnt wait solved myself
0
 

Author Closing Comment

by:PeterBaileyUk
ID: 40300649
i did that and solved it myself, i deleted the question as i didnt see your response, I have selected your answer now hopefully admin will deal with it.
regards
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question