Reputation: 21
i got this error when i am delete record from ms access form in sql server data base and table are linked through odbc connection and delete command written in vb.net please can any one show me solution to this command line written below
DoCmd.RunSQL "Delete from dbo_Main where user = Forms![frm-Examiner]![coUser] "
thanks ramesh
Upvotes: 0
Views: 1461
Reputation: 4582
This error can also occur if the table that's the target of the update/delete is a linked table without a primary key. Add a primary key and relink the table using the Linked Table manager (so Access sees the Primary key).
Upvotes: 0
Reputation: 5386
Combine suggestions from @HansUp and @iDevlop
dim sSql as string
sSql = "Delete from dbo_Main where [user] = '" & Forms![frm-Examiner]![coUser] & "'"
DoCmd.RunSQL sSql
Upvotes: 0
Reputation: 97101
User is a reserved word. Enclose it in square brackets to make sure the db engine treats it as a field name.
DoCmd.RunSQL "Delete from dbo_Main where [user] = Forms![frm-Examiner]![coUser] "
Upvotes: 1
Reputation: 25252
If it's not a permission issue, you could try this:
dim sSql as string
sSql = "Delete from dbo_Main where user = '" & Forms![frm-Examiner]![coUser] & "'"
debug.print sSql
DoCmd.RunSQL sSql
At least it should give you some hints about what's possibly wrong
Upvotes: 1