Solved

cannot edit dao.recordset

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

759 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

18 Experts available now in Live!

Get 1:1 Help Now