UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Problem saving text field using code    
 
   
mattcdse
post Feb 26 2007, 05:48 AM
Post #1

New Member
Posts: 3



Hi all,

In the past in had the usuall bug trying to save data from a text field using a query only to find it has only saved the first so many (256?) characters from the field, truncating the rest. I managed to find some code to overcome this. I now however have a form with two text fields in it. Naturally i thought simply duplicating the code and changing the appropriate bits would solve the problem. Which it did except for one nagging issue. The data is saved perfectly, the form even requeries itself afterwards and displays the updated data, but for some reason Access displays the message "Run time error '3188': Could not update, currently locked by another session on this manchine". When i press the debug button, the line rs.edit is highlighted in yellow.

Any ideas how to get around this - code below

Private Sub btnSave_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strComments As String

'Code to Turn off the warning re runing a query.
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryUpdateSoftImg"
DoCmd.OpenQuery "qryUpdateSoft"

'Update Comments Field
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSoftware", dbOpenTable)
rs.Index = "Software Code"
rs.Seek "=", Me.SoftwareCodeNew
Forms!frmEditSoft!CommentsNew.SetFocus
strComments = Me.CommentsNew.Text
rs.Edit
rs!Comments = strComments
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

'Update Known Issues Field
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSoftware", dbOpenTable)
rs.Index = "Software Code"
rs.Seek "=", Me.SoftwareCodeNew
Forms!frmEditSoft!KnownIssuesNew.SetFocus
strComments = Me.KnownIssuesNew.Text
rs.Edit
rs!KnownIssues = strComments
rs.Update
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing

'Code to Turn the warnings back on.
DoCmd.SetWarnings True

'Reqery the form
Me.Requery

End Sub
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th June 2013 - 08:23 PM