Re: Editing Union results

From: corey lawson (corey.lawson_at_worldnetdotattdotnet)
Date: 12/18/04


Date: Sat, 18 Dec 2004 11:08:06 GMT

John Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:p189r05ikgbkpp3qp9a1iv8oga53t0ni8p@4ax.com:

> On Mon, 6 Dec 2004 05:49:03 -0800, ptb476
> <ptb476@discussions.microsoft.com> wrote:
>
>>I am trying to create a form driven by a Union query where the users
>>can edit the results.
>
> You can't. UNION queries are never updateable and cannot be made
> updateable.

Actually, they can be made editable in some backend RDBMS, like Oracle
8i+, SQL Server 7.0+, etc., by using "INSTEAD OF" triggers on views made
up of "uneditable" queries like union queries.

The INSTEAD OF trigger "catches" the insert, update and/or delete events
and handles things.

It's either that, or write some sort of code (Stored Proc, VBA function)
that does this for you, but this is MUCH harder to pull off for Access,
because if a form's underlying dataset is read-only, your form's bound
controls will be read-only. So you end up having to write event handlers
to scrape-and-paste into unbound form controls, and then somehow turning
the data from the form back into another function back into the database.
Icky stuff worthy of figuring out a better way to do it in your database
design.

Chances are, your design is a common database design mistake. Instead of
having different tables with common information, you have one table with
the common information, and separate tables with the non-common
information. Something like this:

tblPerson:
  personID
  personTypeCode
  lastName
  firstName

tblEmployee
  personID
  employeeID

etc...

And, if you don't code the "person" code in a VBA Class, then you end up
having to do icky repetitive code because Access tables don't expose
anything approaching the functionality of triggers, but if your back-end
database is Oracle, SQL Server, MSDE, etc., then write triggers on the
table to create "child" records for you, which in this case might be like
(almost T-SQL):

  set @newPersonID = select PersonID from inserted

  if Inserted.personTypeCode = 'EM'
    insert into Employee (personid) values(@newPersonID)

...and so on.

Probably the best you could do in the read-only form case is to have it
pop up various editable forms on the chunks of data these can all update.
Of course,



Relevant Pages

  • Re: Controlling Data Formatting
    ... But the fact that you've hit this snag means that your database ... PersonID ... a record in tblPersonsTrainingItems like this: ... >does not require certain training items. ...
    (microsoft.public.access.gettingstarted)
  • data bound combobox does not leave focus
    ... Visual Studio with ADO.NET for the first time (Borland ... I have two test tables in a JET database. ... control type for PersonID to ComboBox in the DataSource ... Combobox to the generated personsBindingSource, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Swap data in multiple fields between 2 records
    ... I understand now the basic concept to swap details ... as u suggested - after I insert the new 'PersonID' inorder to ... follow the links to articles about database normalization. ... swapping with a person Y who was schedules on 30th march. ...
    (microsoft.public.access.formscoding)
  • ADO.Net; Smart Client; Web service - Dataset
    ... Microsoft road map for databound Winforms did not provide much help to ... database table relationships. ... These database tables are joined by personID ... The dataset will be supporting editing and insertions through using ...
    (microsoft.public.data.ado)
  • Re: Order by Char with Int behavior
    ... although both our solutions will sort the same way. ... select 'AA' union select '10' union select '12' ... ORDER BY LEN(PersonID), PersonID ... Jacco Schalkwijk wrote: ...
    (microsoft.public.sqlserver.programming)