Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cannot edit dao.recordset

Posted on 2014-09-03
3
Medium Priority
?
182 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 52

Accepted Solution

by:
Gustav Brock earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

926 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