Solved

cannot edit dao.recordset

Posted on 2014-09-03
3
151 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now