|
-
Mar 16th, 2007, 10:39 AM
#1
Thread Starter
New Member
Access to SQL Server 2005
Hello,
Hopefully someone can help with this.
I am trying to connect an Access front end to a SQL Server backend. At the moment i am successfully running pass-through queries from the front end.
The problem I have is editing the data on the backend using code. When I run the code I get an error saying Cannot Update. Database or object is read-only. I believe this is somthing to do with recordsets or dynasets etc. but I'm new to this and am finding it hard to get information.
The code goes as follows:
Private Sub Command6_Click()
Dim DataMdbLoc
DataMdbLoc = "Products"
Dim DataMDB As Database, ProductTable As Recordset
Set DataMDB = DBEngine.Workspaces(0).OpenDatabase("", True, True, "ODBC;Description=access to SQL Server;DRIVER=SQL Server;SERVER=(local);UID=Administrator;DATABASE=boc;Trusted_Connection=Yes")
Set ProductTable = DataMDB.OpenRecordset("Products", dbOpenDynaset)
'ProductTable.Index = "PrimaryKey"
If ProductTable.EOF Then
MsgBox "There are no records in this table !"
ProductTable.Close
End If
ProductTable.MoveFirst
Do Until ProductTable.EOF
If ProductTable![YearOfManufacture] < 2000 Then
ProductTable.Edit
ProductTable![NeedsNCT] = True
ProductTable.Update ' Update Recordset.
ElseIf ProductTable![YearOfManufacture] >= 2000 Then
ProductTable.Edit
ProductTable![NeedsNCT] = False
ProductTable.Update ' Update Recordset.
End If
ProductTable.MoveNext
Loop
ProductTable.Close ' Close Recordsets.
MsgBox "Update Complete !"
End Sub
If anyone can help with this, it would be greatly appreciated.
DC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|