Mike
Mike

Reputation: 1938

Update to SQL View fails from Access with Linked Table

I have a table that I created a view from. The view really doesn't change anything, except the order of the columns and one column is converted to a varchar from an int.

The view is set up as a linked table in Access 2013. Everything pulls in just fine. When I pull up a form in Access to edit rows in the view I get the problem.

I attempt to update the column OSP_PERCENT_COMPLETE with NA. The end users want this field to not be only an int. I updated the view so that it pulls the column like this:

convert(varchar(10),OSP_PERCENT_COMPLETE) OSP_PERCENT_COMPLETE

So it keeps the same name but is now a varchar field. Then when I go to update that field in the form I get this error message

ODBC--update on a linked table 'PMDBII' failed Access [Microsoft][ODBC SQL Server Driver][SQL Server] Update or Insert of view or function '' failed because it contains a derived or constant field. (#4406)

I can check the field in the PMDBII linked table and it shows it as a short text field with a length of 10.

One thing I should mention, most of this was set up by a coworker who is no longer with the company and I'm not as versed in Access as he was.

So why do I get the error?

Upvotes: 1

Views: 698

Answers (1)

Wayne G. Dunn
Wayne G. Dunn

Reputation: 4312

You get the error because a 'view' does not change the fact that the underlying field is still an 'int'. If you use a form, possibly you could include code on a 'before change' event that translates NA to null, but that could be a bad idea.

Upvotes: 3

Related Questions